Programming:Storing and Retrieving Screens from the extra 64kb

From CPCWiki - THE Amstrad CPC encyclopedia!
Revision as of 03:58, 11 August 2018 by CPM User (Talk | contribs) (The Program)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

This routine comes from the Push-Pop program which was published in Issue 57 of Amstrad Action, however while that program is useful for Storing and Retrieving Screens in the 6128s extra 64k, it's only going to work on the 6128, so other computers with memory expansions won't be able to use it, this updated routine will work on all systems (as long as they have 128kb minimum).

The Routine

The routine works by specifying the RSX command PUSH,<n> with <n> being a number between 1 and 4 to store a screen in banks between c4 and c7 and RSX command POP,<n> restoring that screen (it doesn't delete from where it was stored, unless a new screen is stored there).

Is this routine useful for storing screens for 128k based games? No, not for fast Action games where Animation is constant. A flip screen game would work, though would have to be considered bad to have a 4 screen game using that extra 64k, when there were games like Roland in Time being written in 1984 only occupying 32k and having many screens fully running in 64kb. This routine uses LDIR, which is considered slow, though perhaps useful for Slideshow.

org &a500

ld bc,table
ld hl,workspace
call &bcd1
ret

.workspace
defb 0,0,0,0

.table
defw table2
jp push
jp pop

.table2
defb "PUS"
defb "H"+&80
defb "PO"
defb "P"+&80
defb 0

.push
cp &01
ret nz
ld a,(ix+&00)
cp &05
ret nc
add &c3
ld c,a
ld b,&7f
out (c),c
ld de,&4000
ld hl,&c000
ld bc,&3fff
ldir
ld bc,&7fc0
out (c),c
ret

.pop
cp &01
ret nz
ld a,(ix+&00)
cp &05
ret nc
add &c3
ld c,a
ld b,&7f
out (c),c
ld de,&c000
ld hl,&4000
ld bc,&3fff
ldir
ld bc,&7fc0
out (c),c
ret