Fix table initialization and bank preservateion in _BltRange
This commit is contained in:
parent
cd9eeaf899
commit
ab9a2682db
|
@ -4,7 +4,7 @@
|
|||
;
|
||||
; * 13 banks of memory for the blitter
|
||||
; * 1 bank of memory for the second background
|
||||
; * 1 bank of memory for the second background mask
|
||||
; * 1 bank of memory for the second background alt/mask
|
||||
;
|
||||
; * $01/2000 - $01/9FFF for the shadow screen
|
||||
; * $00/2000 - $00/9FFF for the fixed background
|
||||
|
@ -16,38 +16,38 @@
|
|||
|
||||
mx %00
|
||||
|
||||
MemInit PushLong #0 ; space for result
|
||||
PushLong #$008000 ; size (32k)
|
||||
MemInit PushLong #0 ; space for result
|
||||
PushLong #$008000 ; size (32k)
|
||||
PushWord UserId
|
||||
PushWord #%11000000_00010111 ; Fixed location
|
||||
PushWord #%11000000_00010111 ; Fixed location
|
||||
PushLong #$002000
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_Deref
|
||||
stx Buff00
|
||||
sta Buff00+2
|
||||
|
||||
PushLong #0 ; space for result
|
||||
PushLong #$008000 ; size (32k)
|
||||
PushLong #0 ; space for result
|
||||
PushLong #$008000 ; size (32k)
|
||||
PushWord UserId
|
||||
PushWord #%11000000_00010111 ; Fixed location
|
||||
PushWord #%11000000_00010111 ; Fixed location
|
||||
PushLong #$012000
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_Deref
|
||||
stx Buff01
|
||||
sta Buff01+2
|
||||
|
||||
PushLong #0 ; space for result
|
||||
PushLong #$000A00 ; size (10 pages)
|
||||
PushLong #0 ; space for result
|
||||
PushLong #$000A00 ; size (10 pages)
|
||||
PushWord UserId
|
||||
PushWord #%11000000_00010101 ; Page-aligned, fixed bank
|
||||
PushWord #%11000000_00010101 ; Page-aligned, fixed bank
|
||||
PushLong #$000000
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_Deref
|
||||
stx ZeroPage
|
||||
sta ZeroPage+2
|
||||
|
@ -61,27 +61,42 @@ MemInit PushLong #0 ; space for result
|
|||
]step equ ]step+4
|
||||
--^
|
||||
|
||||
; Fill in a tables with the adddress of all 208 scanlines across all 13 banks
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
lda BlitBuff+2,y ; Copy the high word first
|
||||
:bloop
|
||||
lda BlitBuff+2,y ; Copy the high word first
|
||||
]step equ 0
|
||||
lup 16
|
||||
sta BTableHigh+]step+2,x ; 16 lines per bank
|
||||
sta BTableHigh+]step+2+{208*2},x ; 16 lines per bank
|
||||
]step equ ]step+4
|
||||
sta BTableHigh+]step,x ; 16 lines per bank
|
||||
sta BTableHigh+]step+{208*2},x ; 16 lines per bank
|
||||
]step equ ]step+2
|
||||
--^
|
||||
lda BlitBuff,y
|
||||
sta BTableLow,x
|
||||
sta BTableLow+{208*2},x
|
||||
clc
|
||||
]step equ 0
|
||||
]step equ 2
|
||||
lup 15
|
||||
adc #$1000
|
||||
sta BTableLow+]step,x
|
||||
sta BTableLow+]step+{208*2},x
|
||||
]step equ ]step+4
|
||||
]step equ ]step+2
|
||||
--^
|
||||
|
||||
txa
|
||||
adc #16*2 ; move to the next chunk of BTableHigh and BTableLow
|
||||
tax
|
||||
|
||||
tya
|
||||
adc #4 ; move to the next bank address
|
||||
tay
|
||||
cmp #4*13
|
||||
bcs :exit
|
||||
brl :bloop
|
||||
|
||||
:exit
|
||||
rts
|
||||
|
||||
Buff00 ds 4
|
||||
|
@ -95,12 +110,12 @@ AllocOneBank PushLong #0
|
|||
PushWord UserId
|
||||
PushWord #%11000000_00011100
|
||||
PushLong #0
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
xba ; swap accumulator bytes to XX00
|
||||
sta :bank+2 ; store as bank for next op (overwrite $XX00)
|
||||
:bank ldal $000001,X ; recover the bank address in A=XX/00
|
||||
_NewHandle ; returns LONG Handle on stack
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
xba ; swap accumulator bytes to XX00
|
||||
sta :bank+2 ; store as bank for next op (overwrite $XX00)
|
||||
:bank ldal $000001,X ; recover the bank address in A=XX/00
|
||||
rts
|
||||
|
||||
; Variation that return pointer in the X/A registers (X = low, A = high)
|
||||
|
@ -110,8 +125,8 @@ AllocOneBank2 PushLong #0
|
|||
PushWord #%11000000_00011100
|
||||
PushLong #0
|
||||
_NewHandle
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
plx ; base address of the new handle
|
||||
pla ; high address 00XX of the new handle (bank)
|
||||
_Deref
|
||||
rts
|
||||
|
||||
|
@ -163,6 +178,14 @@ ShutDown rts
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -63,20 +63,20 @@ tiledata ext
|
|||
; one-second timer is generally just used for counters and as a handy
|
||||
; frames-per-second trigger.
|
||||
|
||||
PushLong #0
|
||||
pea $0015 ; Get the existing 1-second interrupt handler and save
|
||||
_GetVector
|
||||
PullLong OldOneSecVec
|
||||
|
||||
pea $0015 ; Set the new handler and enable interrupts
|
||||
PushLong #OneSecHandler
|
||||
_SetVector
|
||||
|
||||
pea $0006
|
||||
_IntSource
|
||||
|
||||
PushLong #VBLTASK ; Also register a Heart Beat Task
|
||||
_SetHeartBeat
|
||||
; PushLong #0
|
||||
; pea $0015 ; Get the existing 1-second interrupt handler and save
|
||||
; _GetVector
|
||||
; PullLong OldOneSecVec
|
||||
;
|
||||
; pea $0015 ; Set the new handler and enable interrupts
|
||||
; PushLong #OneSecHandler
|
||||
; _SetVector
|
||||
;
|
||||
; pea $0006
|
||||
; _IntSource
|
||||
;
|
||||
; PushLong #VBLTASK ; Also register a Heart Beat Task
|
||||
; _SetHeartBeat
|
||||
|
||||
; Start up the graphics engine...
|
||||
|
||||
|
@ -84,9 +84,12 @@ tiledata ext
|
|||
jsr BlitInit ; Initialize the memory
|
||||
jsr GrafInit ; Initialize the graphics screen
|
||||
|
||||
ldx #6 ; Gameboy Advance size
|
||||
ldx #9 ; Special debug size
|
||||
jsr SetScreenMode
|
||||
|
||||
; ldx #6 ; Gameboy Advance size
|
||||
; jsr SetScreenMode
|
||||
|
||||
; Load a picture and copy it into Bank $E1. Then turn on the screen.
|
||||
|
||||
jsr AllocOneBank ; Alloc 64KB for Load/Unpack
|
||||
|
@ -134,15 +137,15 @@ EvtLoop
|
|||
|
||||
; Exit code
|
||||
Exit
|
||||
pea $0007 ; disable 1-second interrupts
|
||||
_IntSource
|
||||
|
||||
PushLong #VBLTASK ; Remove our heartbeat task
|
||||
_DelHeartBeat
|
||||
|
||||
pea $0015
|
||||
PushLong OldOneSecVec ; Reset the interrupt vector
|
||||
_SetVector
|
||||
; pea $0007 ; disable 1-second interrupts
|
||||
; _IntSource
|
||||
;
|
||||
; PushLong #VBLTASK ; Remove our heartbeat task
|
||||
; _DelHeartBeat
|
||||
;
|
||||
; pea $0015
|
||||
; PushLong OldOneSecVec ; Reset the interrupt vector
|
||||
; _SetVector
|
||||
|
||||
PushWord UserId ; Deallocate all of our memory
|
||||
_DisposeAll
|
||||
|
@ -163,15 +166,15 @@ Fatal brk $00
|
|||
; 7. Game Boy Advanced : 30 x 20 240 x 160 (19,200 bytes ( 60.0%))
|
||||
; 8. Ancient Land of Y's : 36 x 16 288 x 128 (18,432 bytes ( 57.6%))
|
||||
; 9. Game Boy Color : 20 x 18 160 x 144 (11,520 bytes ( 36.0%))
|
||||
;
|
||||
; 10. DEBUG : 40 x 1 320 x 1
|
||||
; X=mode number
|
||||
|
||||
]ScreenModeWidth dw 320,272,256,256,280,256,240,288,160
|
||||
]ScreenModeHeight dw 200,192,200,176,160,160,160,128,144
|
||||
]ScreenModeWidth dw 320,272,256,256,280,256,240,288,160,320
|
||||
]ScreenModeHeight dw 200,192,200,176,160,160,160,128,144,1
|
||||
|
||||
SetScreenMode cpx #8
|
||||
SetScreenMode cpx #9
|
||||
bcc :rangeOk
|
||||
ldx #8
|
||||
ldx #9
|
||||
|
||||
:rangeOk txa
|
||||
asl
|
||||
|
@ -279,7 +282,6 @@ DoFrame
|
|||
jsr SetBG0XPos
|
||||
|
||||
jsr Render ; Render the play field
|
||||
|
||||
rts
|
||||
|
||||
; Load a simple picture format onto the SHR screen
|
||||
|
@ -632,6 +634,10 @@ qtRec adrl $0000
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ _BltRange
|
|||
:exit_ptr equ tmp0
|
||||
:jmp_low_save equ tmp2
|
||||
|
||||
phb ; preserve the bank register
|
||||
clc`
|
||||
|
||||
dey
|
||||
|
@ -81,5 +82,8 @@ stk_save lda #0000 ; load the stack
|
|||
sta [:exit_ptr],y
|
||||
rep #$20
|
||||
|
||||
plb ; restore the bank
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ SetBG0XPos
|
|||
; performed in order.
|
||||
;
|
||||
; Experimental -- this is a parameterized version that does not rely on direct page
|
||||
; state variabled for input and attempts to be more optimized.
|
||||
; state variables for input and attempts to be more optimized.
|
||||
;
|
||||
; A = starting virtual line in the code field (0 - 207)
|
||||
; X = number of lines to render (0 - 200)
|
||||
|
@ -533,5 +533,6 @@ SetCodeEntry
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue