SuperCPU Tutorial Listings - Part 8
Listing 8.1
; SuperCPU with SuperRAM-Card
; transfering memory areas
; using Long-LDA and Long-STA
; by M. Mundt for GO64! in 1997
£ba $c000
ldx #$00
copy1:
lda $0400,x ; part of screen
sta $020000,x ; to ramcard
inx
bne copy1
key1:
jsr $f142 ; wait for key
beq key1
ldx #$00
copy2:
lda $020000,x ; move and fill some
sta $07b000,x ; stuff
stz $0400,x
inx
bne copy2
key2:
jsr $f142
beq key2
ldx #$00
copy3:
lda $07b000,x ; restore screen
sta $0400,x
inx
bne copy3
rts
Listing 8.2
; Data Bank Register
; and indirect adressing using
; 3 ZeroPage-Bytes
; by M. Mundt for GO64! in 1997
£ba $c000
sei ; disable IRQ else Crash :)
phb ; save data bank register
lda #$50 ; make a pointer $04a050
sta $fa ; from $fa-$fc
lda #$a0
sta $fb
lda #$04
sta $fc
lda #$21 ; testvalue
sta [$fa] ; to $04a050
; (,y is not needed)
lda #$04 ; bank 4
pha ; becomes
plb ; data bank
; from now on all standard-
; memory-accesses (not long-adressing)
; goes to bank 4!
lda $a050 ; get value from $04a050
sta $000400 ; write to screen ('!')
; sta $0400 would write to $040400 !
lda #$07 ; bank 7 becomes
pha ; data bank
plb
lda $a050
sta $000401
; now the value from $07a050 gets written to
; the screen
lda $04a050
sta $000402
; the most secure way :)
; takes more bytes and a cycle more though
plb ; restore original data bank
; usually (0) :)
cli
rts
Listing 8.3
; SuperCPU with SuperRAM-Card
; Indexing crossing Bank-Boundaries
; written by M.Mundt for GO64! in 1997
£ba $c000
ldx #$00
ldy #0
fill:
tya
sta $0400,x ; fill screen with
iny ; chars 0-255
lda #0 ; nullen in speicher
sta $020000,x ; fill start of bank with
inx ; zero to see what happens
bne fill ; after $02ffff+1
ldx #$00
copyto:
lda $0400,x
sta $02ff80,x
inx
bne copyto
; after $80 bytes are copied address
; $030000 is reached.
; And the CPU stores there for real,
; not to $020000 !
key1:
jsr $f142
beq key1
jsr $e544 ; clr
key2:
jsr $f142
beq key2
ldx #$00
copyback:
lda $02ff80,x ; restore original
sta $0400,x ; screen
lda $020000,x ; visualize zeros
sta $0500,x ; which still should
inx ; be there
bne copyback
rts
Assembler Code © by Malte Mundt
Partial translation and cosmetical changes by Count Zero/SCS*TRC