Fix black screen, text rendering, and keyboard input issues

This commit is contained in:
2025-12-01 22:13:06 +01:00
parent 965e10f6b2
commit a1150081e9
6 changed files with 100 additions and 46 deletions

2
boot.s
View File

@@ -15,7 +15,7 @@ boot_start:
; Load game from disk
move.w #2,28(a1) ; CMD_READ
move.l #$20000,40(a1) ; io_Data
move.l #11776,36(a1) ; io_Length (Exact game size)
move.l #32768,36(a1) ; io_Length (Safe size: 32KB)
move.l #1024,44(a1) ; io_Offset
jsr -456(a6) ; DoIO

View File

@@ -46,11 +46,28 @@ StartGame:
rts
SpawnEmail:
; For now, just pick the first email always, or cycle
; TODO: Randomize
; Check if CurrentEmail is valid, if not start from beginning
move.l CurrentEmail,a0
cmp.l #0,a0
beq.s .firstEmail
; Advance to next email (26 bytes per email structure)
add.l #26,a0
; Check if we've reached the end
lea EmailListEnd,a1
cmp.l a1,a0
bge.s .firstEmail
; Valid email, use it
move.l a0,CurrentEmail
bra.s .draw
.firstEmail:
lea EmailList,a0
move.l a0,CurrentEmail
.draw:
bsr DrawEmail
rts
@@ -62,34 +79,34 @@ DrawEmail:
; Draw Sender (at 2, 12)
move.l 2(a0),a0 ; Get Sender Ptr
moveq #2,d0 ; X
moveq #12,d1 ; Y
moveq #30,d1 ; Y
bsr DrawText
; Draw Subject (at 2, 14)
move.l CurrentEmail,a0
move.l 6(a0),a0 ; Get Subject Ptr
moveq #2,d0
moveq #14,d1
moveq #45,d1
bsr DrawText
; Draw Body (at 2, 16)
move.l CurrentEmail,a0
move.l 10(a0),a0 ; Get Body Ptr
moveq #2,d0
moveq #16,d1
moveq #60,d1
bsr DrawText
; Draw Options (at 2, 20 and 2, 22)
move.l CurrentEmail,a0
move.l 14(a0),a0 ; Opt1
moveq #2,d0
moveq #20,d1
moveq #90,d1
bsr DrawText
move.l CurrentEmail,a0
move.l 18(a0),a0 ; Opt2
moveq #2,d0
moveq #22,d1
moveq #105,d1
bsr DrawText
.done:

View File

@@ -35,16 +35,16 @@ START:
move.w #$0000,COLOR00(a6)
move.w #$0FF0,COLOR01(a6)
; Simple copper
lea Copper(pc),a0
move.l a0,d0
move.w d0,COP1LCL(a6)
swap d0
move.w d0,COP1LCH(a6)
move.w #0,COPJMP1(a6)
; Simple copper - DISABLED for debugging
; lea Copper(pc),a0
; move.l a0,d0
; move.w d0,COP1LCL(a6)
; swap d0
; move.w d0,COP1LCH(a6)
; move.w #0,COPJMP1(a6)
; Enable DMA: Bitplane + Copper
move.w #$8380,DMACON(a6) ; Set DMAEN + COPEN + BPLEN
; Enable DMA: Bitplane only (No Copper)
move.w #$8100,DMACON(a6) ; Set DMAEN + BPLEN
; Clear screen
lea Screen(pc),a0
@@ -70,11 +70,13 @@ START:
bsr DrawText
LOOP:
; Simple VBlank wait
move.l CUSTOM+$004,d0
; Robust VBlank wait
lea CUSTOM,a6
.wait_vblank:
move.l $004(a6),d0 ; VPOSR is at offset 4
and.l #$1ff00,d0
cmp.l #$13000,d0
bne.s LOOP
cmp.l #300<<8,d0 ; Wait for line 300
bne.s .wait_vblank
; Check mouse
btst #6,CIAA

View File

@@ -60,7 +60,7 @@ ClearScreen:
; DrawText
; d0 = X, d1 = Y, a0 = String
DrawText:
movem.l d0-d3/a0-a2,-(sp)
movem.l d0-d4/a0-a2,-(sp)
; d0 = Initial X (keep in d3 for CR)
move.w d0,d3
@@ -99,7 +99,7 @@ DrawText:
bra.s .charLoop
.newline:
addq.w #1,d1 ; Increment Y (lines)
addq.w #8,d1 ; Increment Y (8 lines for font height)
bsr .calcAddr ; Recalculate address (Resets X to d3)
bra.s .charLoop
@@ -109,13 +109,13 @@ DrawText:
bra.s .charLoop
.done:
movem.l (sp)+,d0-d3/a0-a2
movem.l (sp)+,d0-d4/a0-a2
rts
.calcAddr:
lea Bitplane1,a1
move.l d1,d4 ; Copy Y
mulu #320,d4 ; Y * 320
mulu #40,d4 ; Y * 40 (Bytes per line)
add.l d4,a1
add.w d3,a1 ; Add Initial X
rts
@@ -125,7 +125,7 @@ DrawText:
DrawChar:
movem.l d0-d3/a0-a2,-(sp)
lea Bitplane1,a1
mulu #320,d1
mulu #40,d1
add.l d1,a1
add.w d0,a1

50
input.s
View File

@@ -13,10 +13,54 @@
; Returns: d0 = Raw Keycode (or 0 if no key)
; Preserves: d1-a6
ReadInput:
moveq #0,d0 ; Default: no key
movem.l d1-d2/a0,-(sp)
; Simple approach: just return 0 for now (disable keyboard)
; This prevents crashes from keyboard input
; Check if LastKey is still pending (not yet processed)
move.b LastKey,d0
cmp.b #0,d0
bne.s .done ; Still has unprocessed key, don't read new one
; Simple keyboard matrix scan for keys '1' and '2'
; Key '1' = Row 0, Column 1 (raw code $01)
; Key '2' = Row 0, Column 2 (raw code $02)
lea $bfe001,a0 ; CIAA base
; Set all rows to output, columns to input
move.b #$ff,$bfe201 ; CIAA DDRA (all output)
move.b #$00,$bfe301 ; CIAA DDRB (all input)
; Scan Row 0 (contains keys 1 and 2)
move.b #$fe,$bfe001 ; Set row 0 low (active), others high
nop
nop ; Small delay for signal to settle
move.b $bfe101,d1 ; Read columns from Port B
not.b d1 ; Invert (pressed = 1)
; Check column 1 (key '1')
btst #1,d1
bne.s .key1
; Check column 2 (key '2')
btst #2,d1
bne.s .key2
; No key pressed
moveq #0,d0
bra.s .done
.key1:
move.b #$01,d0
move.b d0,LastKey
bra.s .done
.key2:
move.b #$02,d0
move.b d0,LastKey
.done:
movem.l (sp)+,d1-d2/a0
rts
; TODO: Implement proper keyboard reading later

23
main.s
View File

@@ -38,6 +38,7 @@ START:
; Enable DMA for Copper, Bitplanes, Blitter
move.w #$83C0,DMACON(a6) ; Set DMAEN, BPLEN, COPEN, BLTEN
move.w #0,COPJMP1(a6) ; Strobe Copper to start immediately
MAIN_LOOP:
; Wait for vertical blank
@@ -49,25 +50,15 @@ MAIN_LOOP:
; 2. Update Game Logic
bsr UpdateGame
; 3. Check for Exit (Left Mouse Button for now)
; 3. Check for Reset (Left Mouse Button)
btst #6,CIAA
bne.s MAIN_LOOP
EXIT:
; Restore System
lea CUSTOM,a6
move.w #$7FFF,DMACON(a6)
move.w #$7FFF,INTENA(a6)
; If button pressed, restart game
bra START
move.w OldDmaCon,DMACON(a6)
move.w OldIntEna,INTENA(a6)
; Enable multitasking
; move.l 4.w,a6
; jsr -138(a6) ; Permit
moveq #0,d0
rts
; EXIT label removed as we don't return to OS
; The bootblock environment has no OS to return to cleanly in this simple setup
; ---------------------------------------------------------------------------
; Helper Routines
@@ -78,7 +69,7 @@ WaitVBlank:
.wait:
move.l $04(a6),d0
and.l #$1ff00,d0
cmp.l #300<<8,d0
cmp.l #250<<8,d0
bne.s .wait
rts