Fix black screen, text rendering, and keyboard input issues
This commit is contained in:
2
boot.s
2
boot.s
@@ -15,7 +15,7 @@ boot_start:
|
|||||||
; Load game from disk
|
; Load game from disk
|
||||||
move.w #2,28(a1) ; CMD_READ
|
move.w #2,28(a1) ; CMD_READ
|
||||||
move.l #$20000,40(a1) ; io_Data
|
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
|
move.l #1024,44(a1) ; io_Offset
|
||||||
|
|
||||||
jsr -456(a6) ; DoIO
|
jsr -456(a6) ; DoIO
|
||||||
|
|||||||
31
game_logic.s
31
game_logic.s
@@ -46,11 +46,28 @@ StartGame:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
SpawnEmail:
|
SpawnEmail:
|
||||||
; For now, just pick the first email always, or cycle
|
; Check if CurrentEmail is valid, if not start from beginning
|
||||||
; TODO: Randomize
|
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
|
lea EmailList,a0
|
||||||
move.l a0,CurrentEmail
|
move.l a0,CurrentEmail
|
||||||
|
|
||||||
|
.draw:
|
||||||
bsr DrawEmail
|
bsr DrawEmail
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@@ -62,34 +79,34 @@ DrawEmail:
|
|||||||
; Draw Sender (at 2, 12)
|
; Draw Sender (at 2, 12)
|
||||||
move.l 2(a0),a0 ; Get Sender Ptr
|
move.l 2(a0),a0 ; Get Sender Ptr
|
||||||
moveq #2,d0 ; X
|
moveq #2,d0 ; X
|
||||||
moveq #12,d1 ; Y
|
moveq #30,d1 ; Y
|
||||||
bsr DrawText
|
bsr DrawText
|
||||||
|
|
||||||
; Draw Subject (at 2, 14)
|
; Draw Subject (at 2, 14)
|
||||||
move.l CurrentEmail,a0
|
move.l CurrentEmail,a0
|
||||||
move.l 6(a0),a0 ; Get Subject Ptr
|
move.l 6(a0),a0 ; Get Subject Ptr
|
||||||
moveq #2,d0
|
moveq #2,d0
|
||||||
moveq #14,d1
|
moveq #45,d1
|
||||||
bsr DrawText
|
bsr DrawText
|
||||||
|
|
||||||
; Draw Body (at 2, 16)
|
; Draw Body (at 2, 16)
|
||||||
move.l CurrentEmail,a0
|
move.l CurrentEmail,a0
|
||||||
move.l 10(a0),a0 ; Get Body Ptr
|
move.l 10(a0),a0 ; Get Body Ptr
|
||||||
moveq #2,d0
|
moveq #2,d0
|
||||||
moveq #16,d1
|
moveq #60,d1
|
||||||
bsr DrawText
|
bsr DrawText
|
||||||
|
|
||||||
; Draw Options (at 2, 20 and 2, 22)
|
; Draw Options (at 2, 20 and 2, 22)
|
||||||
move.l CurrentEmail,a0
|
move.l CurrentEmail,a0
|
||||||
move.l 14(a0),a0 ; Opt1
|
move.l 14(a0),a0 ; Opt1
|
||||||
moveq #2,d0
|
moveq #2,d0
|
||||||
moveq #20,d1
|
moveq #90,d1
|
||||||
bsr DrawText
|
bsr DrawText
|
||||||
|
|
||||||
move.l CurrentEmail,a0
|
move.l CurrentEmail,a0
|
||||||
move.l 18(a0),a0 ; Opt2
|
move.l 18(a0),a0 ; Opt2
|
||||||
moveq #2,d0
|
moveq #2,d0
|
||||||
moveq #22,d1
|
moveq #105,d1
|
||||||
bsr DrawText
|
bsr DrawText
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
|
|||||||
@@ -35,16 +35,16 @@ START:
|
|||||||
move.w #$0000,COLOR00(a6)
|
move.w #$0000,COLOR00(a6)
|
||||||
move.w #$0FF0,COLOR01(a6)
|
move.w #$0FF0,COLOR01(a6)
|
||||||
|
|
||||||
; Simple copper
|
; Simple copper - DISABLED for debugging
|
||||||
lea Copper(pc),a0
|
; lea Copper(pc),a0
|
||||||
move.l a0,d0
|
; move.l a0,d0
|
||||||
move.w d0,COP1LCL(a6)
|
; move.w d0,COP1LCL(a6)
|
||||||
swap d0
|
; swap d0
|
||||||
move.w d0,COP1LCH(a6)
|
; move.w d0,COP1LCH(a6)
|
||||||
move.w #0,COPJMP1(a6)
|
; move.w #0,COPJMP1(a6)
|
||||||
|
|
||||||
; Enable DMA: Bitplane + Copper
|
; Enable DMA: Bitplane only (No Copper)
|
||||||
move.w #$8380,DMACON(a6) ; Set DMAEN + COPEN + BPLEN
|
move.w #$8100,DMACON(a6) ; Set DMAEN + BPLEN
|
||||||
|
|
||||||
; Clear screen
|
; Clear screen
|
||||||
lea Screen(pc),a0
|
lea Screen(pc),a0
|
||||||
@@ -70,12 +70,14 @@ START:
|
|||||||
bsr DrawText
|
bsr DrawText
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
; Simple VBlank wait
|
; Robust VBlank wait
|
||||||
move.l CUSTOM+$004,d0
|
lea CUSTOM,a6
|
||||||
|
.wait_vblank:
|
||||||
|
move.l $004(a6),d0 ; VPOSR is at offset 4
|
||||||
and.l #$1ff00,d0
|
and.l #$1ff00,d0
|
||||||
cmp.l #$13000,d0
|
cmp.l #300<<8,d0 ; Wait for line 300
|
||||||
bne.s LOOP
|
bne.s .wait_vblank
|
||||||
|
|
||||||
; Check mouse
|
; Check mouse
|
||||||
btst #6,CIAA
|
btst #6,CIAA
|
||||||
bne.s LOOP
|
bne.s LOOP
|
||||||
|
|||||||
10
graphics.s
10
graphics.s
@@ -60,7 +60,7 @@ ClearScreen:
|
|||||||
; DrawText
|
; DrawText
|
||||||
; d0 = X, d1 = Y, a0 = String
|
; d0 = X, d1 = Y, a0 = String
|
||||||
DrawText:
|
DrawText:
|
||||||
movem.l d0-d3/a0-a2,-(sp)
|
movem.l d0-d4/a0-a2,-(sp)
|
||||||
|
|
||||||
; d0 = Initial X (keep in d3 for CR)
|
; d0 = Initial X (keep in d3 for CR)
|
||||||
move.w d0,d3
|
move.w d0,d3
|
||||||
@@ -99,7 +99,7 @@ DrawText:
|
|||||||
bra.s .charLoop
|
bra.s .charLoop
|
||||||
|
|
||||||
.newline:
|
.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)
|
bsr .calcAddr ; Recalculate address (Resets X to d3)
|
||||||
bra.s .charLoop
|
bra.s .charLoop
|
||||||
|
|
||||||
@@ -109,13 +109,13 @@ DrawText:
|
|||||||
bra.s .charLoop
|
bra.s .charLoop
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
movem.l (sp)+,d0-d3/a0-a2
|
movem.l (sp)+,d0-d4/a0-a2
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.calcAddr:
|
.calcAddr:
|
||||||
lea Bitplane1,a1
|
lea Bitplane1,a1
|
||||||
move.l d1,d4 ; Copy Y
|
move.l d1,d4 ; Copy Y
|
||||||
mulu #320,d4 ; Y * 320
|
mulu #40,d4 ; Y * 40 (Bytes per line)
|
||||||
add.l d4,a1
|
add.l d4,a1
|
||||||
add.w d3,a1 ; Add Initial X
|
add.w d3,a1 ; Add Initial X
|
||||||
rts
|
rts
|
||||||
@@ -125,7 +125,7 @@ DrawText:
|
|||||||
DrawChar:
|
DrawChar:
|
||||||
movem.l d0-d3/a0-a2,-(sp)
|
movem.l d0-d3/a0-a2,-(sp)
|
||||||
lea Bitplane1,a1
|
lea Bitplane1,a1
|
||||||
mulu #320,d1
|
mulu #40,d1
|
||||||
add.l d1,a1
|
add.l d1,a1
|
||||||
add.w d0,a1
|
add.w d0,a1
|
||||||
|
|
||||||
|
|||||||
50
input.s
50
input.s
@@ -13,10 +13,54 @@
|
|||||||
; Returns: d0 = Raw Keycode (or 0 if no key)
|
; Returns: d0 = Raw Keycode (or 0 if no key)
|
||||||
; Preserves: d1-a6
|
; Preserves: d1-a6
|
||||||
ReadInput:
|
ReadInput:
|
||||||
moveq #0,d0 ; Default: no key
|
movem.l d1-d2/a0,-(sp)
|
||||||
|
|
||||||
; Simple approach: just return 0 for now (disable keyboard)
|
; Check if LastKey is still pending (not yet processed)
|
||||||
; This prevents crashes from keyboard input
|
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
|
rts
|
||||||
|
|
||||||
; TODO: Implement proper keyboard reading later
|
; TODO: Implement proper keyboard reading later
|
||||||
|
|||||||
23
main.s
23
main.s
@@ -38,6 +38,7 @@ START:
|
|||||||
|
|
||||||
; Enable DMA for Copper, Bitplanes, Blitter
|
; Enable DMA for Copper, Bitplanes, Blitter
|
||||||
move.w #$83C0,DMACON(a6) ; Set DMAEN, BPLEN, COPEN, BLTEN
|
move.w #$83C0,DMACON(a6) ; Set DMAEN, BPLEN, COPEN, BLTEN
|
||||||
|
move.w #0,COPJMP1(a6) ; Strobe Copper to start immediately
|
||||||
|
|
||||||
MAIN_LOOP:
|
MAIN_LOOP:
|
||||||
; Wait for vertical blank
|
; Wait for vertical blank
|
||||||
@@ -49,25 +50,15 @@ MAIN_LOOP:
|
|||||||
; 2. Update Game Logic
|
; 2. Update Game Logic
|
||||||
bsr UpdateGame
|
bsr UpdateGame
|
||||||
|
|
||||||
; 3. Check for Exit (Left Mouse Button for now)
|
; 3. Check for Reset (Left Mouse Button)
|
||||||
btst #6,CIAA
|
btst #6,CIAA
|
||||||
bne.s MAIN_LOOP
|
bne.s MAIN_LOOP
|
||||||
|
|
||||||
EXIT:
|
; If button pressed, restart game
|
||||||
; Restore System
|
bra START
|
||||||
lea CUSTOM,a6
|
|
||||||
move.w #$7FFF,DMACON(a6)
|
|
||||||
move.w #$7FFF,INTENA(a6)
|
|
||||||
|
|
||||||
move.w OldDmaCon,DMACON(a6)
|
|
||||||
move.w OldIntEna,INTENA(a6)
|
|
||||||
|
|
||||||
; Enable multitasking
|
; EXIT label removed as we don't return to OS
|
||||||
; move.l 4.w,a6
|
; The bootblock environment has no OS to return to cleanly in this simple setup
|
||||||
; jsr -138(a6) ; Permit
|
|
||||||
|
|
||||||
moveq #0,d0
|
|
||||||
rts
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Helper Routines
|
; Helper Routines
|
||||||
@@ -78,7 +69,7 @@ WaitVBlank:
|
|||||||
.wait:
|
.wait:
|
||||||
move.l $04(a6),d0
|
move.l $04(a6),d0
|
||||||
and.l #$1ff00,d0
|
and.l #$1ff00,d0
|
||||||
cmp.l #300<<8,d0
|
cmp.l #250<<8,d0
|
||||||
bne.s .wait
|
bne.s .wait
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user