pouët.net

lovebytecraft by sibCrew

; ..lovebytecraft - an invitro to lovebyte 2o24
; --wbcbz7 -- o7.o2.2o24
; 235b/pc/dos/textmoooooode!
;
; quick hack of firecraft (https://www.pouet.net/prod.php?which=95798)
; for lovebyte 2024 countdo^W oldskool 256b compo
; designed for LOW LOW LOW cycles count (like XT/CGA)
;

        org     0x100
        use16

start:
        ; set color 40x25 mode
        inc     ax              
        int     0x10
        xor     ax, ax
        
        ; disable damn cursor
        mov     ah, 1
        mov     ch, 0x20
        int     0x10

        ; setup segments
        mov     ah, 0xB8        ; set textmode frame buffer segment
        mov     es, ax
        mov     ax, 0xFFA6      ; BIOS 8x8 font segment (off 0xE bytes, lol why ibm?)
        mov     ds, ax
    
        ; frame loop
.loop:
        ; frame limit
        ; put here for less flickering
        hlt
        mov     dx, 0x3DA
.2:
        in      al, dx
        test    al, 8
        jnz      .2

        rol     bx, 1

        in      al, 0x40
        or      al, 0x80
        mov     cl, al

        mov     si, (40 * 26 * 2)
        xor     di, di
.smloop:
        mov     al, [es:si]
        or      al, [es:di+82]
        or      al, [es:di+2]
        add     al, cl
        sbb     ah, ah                  ; saturation
        and     al, ah
        mov     ah, 0x01
        stosw
        out     0x61, al                ; and play with speaker 
        cmp     di, si
        jnz     .smloop

        in      al, 0x40
        and     ax, bp
test    al, 0xC0                        ; check if to draw current string
        jz      .done
        call    print 

        ; draw logo
        mov     si, [cs:lbtext.charpos]
        cmp     si, lbtext.stop
        jb      .fetch_char
        mov     si, lbtext
.fetch_char:
        xor     ax, ax
        ; fetch character
        mov     al, [cs:si]
        test    bp, 3
        jnz     .no_inc
        inc     si
.no_inc:
        mov     [cs:lbtext.charpos], si
        mov     cl, 3
        shl     ax, cl
        mov     si, ax
        add     si, 0x0E       ; character offset

        ; get random position
        in      al, 0x40
        and     ax, 0x0e
        add     ax, (40*((25 - 12)/2) + 13)*2
        ;mov     ax, (40*((25 - 12)/2) + 8)*2
        mov     di, ax

        ; SI - character offset in font segment
        mov     cx, 8
.lineloop:
        mov     bl, 0x80
        mov     bh, [si]
.charloop:
        shl     bx, 1
        jz      .next_byte
        sbb     ax, ax
        jz      .advance
        and     ax, 0x0CDB              ; solid fill because it looks better
        mov     [es:di], ax
        out     0x42, al
.advance:
        add     di, 4
        jmp     .charloop

.next_byte:
        sub     di, -(2*80 - 32)
        inc     si
        loop    .lineloop

.done:
        inc     bp
        ; kbhit() - doesn't work on XT since keyboard is locked out :(
        in      al, 0x60
        dec     al
        jz      .ret
        jmp     .loop

        ; and back to dos
.ret:
        ret 

        ; draw directly on screen, DOS/BIOS functions are too slow
print:
        mov     si, lbtext
        mov     di, 40*24*2
.loop:
        cs      lodsb
        test    al, al
        jz      start.ret
        stosb
        inc     di
        jmp     .loop


lbtext  db  3,3,3,"=[",3,"lovebyte.2024",3,"]=",3,3,3,"less is more",3,3,3
     ;  db  3,3,3,"=[",3,"lovebyte.2024",3,"]=",3,3,3,"1 day to go!",3,3,3 
.stop   db  0
.charpos dw lbtext