2020-08-19 05:35:30 +00:00
|
|
|
; Initialize the system for fun!
|
|
|
|
;
|
|
|
|
; Mostly memory allocation
|
|
|
|
;
|
|
|
|
; * 13 banks of memory for the blitter
|
|
|
|
; * 1 bank of memory for the second background
|
2021-07-10 20:38:42 +00:00
|
|
|
; * 1 bank of memory for the second background alt/mask
|
2020-08-19 05:35:30 +00:00
|
|
|
;
|
|
|
|
; * $01/2000 - $01/9FFF for the shadow screen
|
|
|
|
; * $00/2000 - $00/9FFF for the fixed background
|
|
|
|
;
|
|
|
|
; * 10 pages of direct page in Bank $00
|
|
|
|
; - 1 page for scratch space
|
|
|
|
; - 1 page for pointer to the second background
|
|
|
|
; - 8 pages for the dynamic tiles
|
|
|
|
|
2020-08-28 04:01:28 +00:00
|
|
|
mx %00
|
|
|
|
|
2021-07-10 20:38:42 +00:00
|
|
|
MemInit PushLong #0 ; space for result
|
|
|
|
PushLong #$008000 ; size (32k)
|
2020-08-28 04:01:28 +00:00
|
|
|
PushWord UserId
|
2021-07-10 20:38:42 +00:00
|
|
|
PushWord #%11000000_00010111 ; Fixed location
|
2020-08-28 04:01:28 +00:00
|
|
|
PushLong #$002000
|
2021-07-10 20:38:42 +00:00
|
|
|
_NewHandle ; returns LONG Handle on stack
|
|
|
|
plx ; base address of the new handle
|
|
|
|
pla ; high address 00XX of the new handle (bank)
|
2020-08-28 04:01:28 +00:00
|
|
|
_Deref
|
|
|
|
stx Buff00
|
|
|
|
sta Buff00+2
|
|
|
|
|
2021-07-10 20:38:42 +00:00
|
|
|
PushLong #0 ; space for result
|
|
|
|
PushLong #$008000 ; size (32k)
|
2020-08-28 04:01:28 +00:00
|
|
|
PushWord UserId
|
2021-07-10 20:38:42 +00:00
|
|
|
PushWord #%11000000_00010111 ; Fixed location
|
2020-08-28 04:01:28 +00:00
|
|
|
PushLong #$012000
|
2021-07-10 20:38:42 +00:00
|
|
|
_NewHandle ; returns LONG Handle on stack
|
|
|
|
plx ; base address of the new handle
|
|
|
|
pla ; high address 00XX of the new handle (bank)
|
2020-08-28 04:01:28 +00:00
|
|
|
_Deref
|
|
|
|
stx Buff01
|
|
|
|
sta Buff01+2
|
|
|
|
|
2021-07-10 20:38:42 +00:00
|
|
|
PushLong #0 ; space for result
|
|
|
|
PushLong #$000A00 ; size (10 pages)
|
2020-08-28 04:01:28 +00:00
|
|
|
PushWord UserId
|
2021-07-10 20:38:42 +00:00
|
|
|
PushWord #%11000000_00010101 ; Page-aligned, fixed bank
|
2020-08-28 04:01:28 +00:00
|
|
|
PushLong #$000000
|
2021-07-10 20:38:42 +00:00
|
|
|
_NewHandle ; returns LONG Handle on stack
|
|
|
|
plx ; base address of the new handle
|
|
|
|
pla ; high address 00XX of the new handle (bank)
|
2020-08-28 04:01:28 +00:00
|
|
|
_Deref
|
2021-07-16 05:34:58 +00:00
|
|
|
stx BlitterDP
|
|
|
|
|
2021-07-16 22:05:29 +00:00
|
|
|
; Allocate banks of memory for BG1
|
2021-07-16 05:34:58 +00:00
|
|
|
jsr AllocOneBank2
|
|
|
|
sta BG1DataBank
|
2020-08-28 04:01:28 +00:00
|
|
|
|
2021-07-16 22:05:29 +00:00
|
|
|
jsr AllocOneBank2
|
|
|
|
sta BG1AltBank
|
|
|
|
|
2020-11-30 12:38:20 +00:00
|
|
|
; Allocate the 13 banks of memory we need and store in double-length array
|
2020-08-28 04:01:28 +00:00
|
|
|
]step equ 0
|
|
|
|
lup 13
|
|
|
|
jsr AllocOneBank2
|
|
|
|
sta BlitBuff+]step+2
|
|
|
|
stz BlitBuff+]step
|
2021-07-08 12:46:35 +00:00
|
|
|
]step equ ]step+4
|
|
|
|
--^
|
|
|
|
|
2021-07-10 20:38:42 +00:00
|
|
|
; Fill in a tables with the adddress of all 208 scanlines across all 13 banks
|
|
|
|
|
2021-07-08 12:46:35 +00:00
|
|
|
ldx #0
|
|
|
|
ldy #0
|
2021-07-10 20:38:42 +00:00
|
|
|
:bloop
|
|
|
|
lda BlitBuff+2,y ; Copy the high word first
|
2021-07-08 12:46:35 +00:00
|
|
|
]step equ 0
|
|
|
|
lup 16
|
2021-07-10 20:38:42 +00:00
|
|
|
sta BTableHigh+]step,x ; 16 lines per bank
|
|
|
|
sta BTableHigh+]step+{208*2},x ; 16 lines per bank
|
|
|
|
]step equ ]step+2
|
2021-07-08 12:46:35 +00:00
|
|
|
--^
|
|
|
|
lda BlitBuff,y
|
|
|
|
sta BTableLow,x
|
|
|
|
sta BTableLow+{208*2},x
|
|
|
|
clc
|
2021-07-10 20:38:42 +00:00
|
|
|
]step equ 2
|
2021-07-08 12:46:35 +00:00
|
|
|
lup 15
|
|
|
|
adc #$1000
|
|
|
|
sta BTableLow+]step,x
|
|
|
|
sta BTableLow+]step+{208*2},x
|
2021-07-10 20:38:42 +00:00
|
|
|
]step equ ]step+2
|
2020-08-28 04:01:28 +00:00
|
|
|
--^
|
|
|
|
|
2021-07-10 20:38:42 +00:00
|
|
|
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
|
2020-08-28 04:01:28 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
Buff00 ds 4
|
|
|
|
Buff01 ds 4
|
|
|
|
|
2020-08-23 05:25:39 +00:00
|
|
|
; Bank allocator (for one full, fixed bank of memory. Can be immediately deferenced)
|
|
|
|
|
2020-08-28 04:01:28 +00:00
|
|
|
AllocOneBank PushLong #0
|
|
|
|
PushLong #$10000
|
|
|
|
PushWord UserId
|
|
|
|
PushWord #%11000000_00011100
|
|
|
|
PushLong #0
|
2021-07-10 20:38:42 +00: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
|
2020-08-28 04:01:28 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; Variation that return pointer in the X/A registers (X = low, A = high)
|
|
|
|
AllocOneBank2 PushLong #0
|
|
|
|
PushLong #$10000
|
|
|
|
PushWord UserId
|
|
|
|
PushWord #%11000000_00011100
|
|
|
|
PushLong #0
|
|
|
|
_NewHandle
|
2021-07-10 20:38:42 +00:00
|
|
|
plx ; base address of the new handle
|
|
|
|
pla ; high address 00XX of the new handle (bank)
|
2020-08-28 04:01:28 +00:00
|
|
|
_Deref
|
|
|
|
rts
|
2020-08-23 05:25:39 +00:00
|
|
|
|
|
|
|
; Set up the interrupts
|
|
|
|
;
|
|
|
|
; oldOneVect = GetVector( oneSecHnd );
|
|
|
|
; SetVector( oneSecHnd, (Pointer) ONEHANDLER );
|
|
|
|
; IntSource( oSecEnable );
|
|
|
|
; SetHeartBeat( VBLTASK );
|
2020-08-28 04:01:28 +00:00
|
|
|
IntInit rts
|
2020-08-23 05:25:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
; IntSource( oSecDisable ); /* disable one second interrupts */
|
|
|
|
; SetVector( oneSecHnd, oldOneVect ); /* reset to the old handler */
|
2020-08-28 04:01:28 +00:00
|
|
|
ShutDown rts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-23 05:25:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 05:35:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-30 12:38:20 +00:00
|
|
|
|
|
|
|
|
2021-07-08 12:46:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-30 12:38:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-10 20:38:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-30 12:38:20 +00:00
|
|
|
|
2020-08-19 05:35:30 +00:00
|
|
|
|
|
|
|
|
2021-07-16 05:34:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 05:35:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-16 22:05:29 +00:00
|
|
|
|
2020-08-19 05:35:30 +00:00
|
|
|
|
|
|
|
|