;;
; Example of simple part that relies on the demo system and it s automatic music play
; No init are used for this part
;
; Of course parts can be written with any assembler as soon as the API contracts are respected.
; I'm pretty sure my files are rasm compatible
include "demosystem/public_macros.asm"
include "contract/part1.asm"
org PART1_LOADING_AREA
;;
; Each part must start with these 3 jump blocks
; So systematically 6 bytes that compress badly are lost
; In case no init is used, set the address to demo_system_address_of_a_ret
part1
dw init_assets_with_firmware ; System has not been killed yet, it is then possible to use it to build/compute stuff
; this is called one time just after deo launched
dw init_assets_without_firmware ; Some other init may prfere a killed system.
; it is better to lost 3 bytes rather than plenty more by saving firmware state
dw play_part ;
;;
; First stage init.
; Print a string using the firmware
init_assets_with_firmware
ld hl, .txt
.loop
ld a, (hl) : inc hl
or a : ret z
call 0xbb5a
jr .loop
.txt db 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, "Part 1 uses firmware in first init stage, then clears some screen area in second stage. It's effect only consists in writting random bytes in the first 256 bytes of screen. Music is played under interruption by the system."
db 10, 13
db 0
;;
; Second stage init.
; Clear some bytes on screen
init_assets_without_firmware
ld hl, 0xc000 + 80 * 5
ld de, 0xc000 + 80 * 5 + 1
ld bc, 256
ld (hl), 255
ldir
ret
;;
; A fake part that write random things on memory screen
play_part
; todo register a gunction to leave properly
; just a garbage effect to verify we loop and play the music
ld hl, 0xc000
.frame_loop
ld b, 50
.code_loop
ld a, r
ld (hl), a
inc l
djnz .code_loop
; Only a limit amount of frames is allowed (init included)
; so we loop only if the system gives the authorization
DS_CHECK_IF_MUST_LEAVE (void)
jp nz, .frame_loop
.leave
; cleanup the mess
ld hl, 0xc000
ld de, 0xc000 + 1
ld bc, 256
ld (hl), l
ldir
if 0
; lost lots of time to see the screen cleanup
ld b, 50*3
.slow_down
push bc
DS_WAIT_VSYNC (void)
halt
halt
pop bc
djnz .slow_down
endif
; music is already under interruption, so there is no need to activate it again
DS_LAUNCH_NEXT_PART (void)
;;
; Example of part that
; - does some inits
; - manually plays the music
; - make use of the data space in the banks
;
; Of course parts can be written with any assembler as soon as the API contracts are respected.
; I'm pretty sure my files are rasm compatible
include "demosystem/public_macros.asm"
include "contract/part2.asm"
org PART2_LOADING_AREA
FOREVER_VARIABLE_SPACE equ PART2_AVAILABLE_MEMORY_SPACE_FIRST_BYTE
VARIABLE1_RELATIVE_POSITION equ 0 ; a word that change over time
VARIABLE2_RELATIVE_POSITION equ 2 ; a byte to chose the palette
;;
; Each part must start with these 3 jump blocks
; So systematically 6 bytes that compress badly are lost
part2
dw init_assets_with_firmware ; System has not been killed yet, it is then possible to use it to build/compute stuff
; this is called one time just after deo launched
dw init_assets_without_firmware ; Some other init may prfere a killed system.
; it is better to lost 3 bytes rather than plenty more by saving firmware state
dw play_part ;
;;
; the part uses the firmware for some init stuff
init_assets_with_firmware
; some fake data storage to test memory access
ld bc, 0x7f00 + PART2_DATA_BANK : out (c), c
ld hl, 0xdead
ld (FOREVER_VARIABLE_SPACE + VARIABLE1_RELATIVE_POSITION + 0), hl
ld bc, 0x7f00 + 0xc0 : out (c), c
ld hl, .msg
.loop
ld a, (hl) : or a : ret z
inc hl
call 0xbb5a
jr .loop
.msg db 10, "Part 2 uses system and write 0xdead in its dedicatd space during init 1, then 0xbeef in init 2. The effect continuously changes these values one time per call. Music is manually played and its duration is shown. Persistent memory is used to count the number of runs and select the palette", 0
;;
; This init is done when firmware is not used
init_assets_without_firmware
assert $<0x4000
; Some fake data storage to replace the previous one
ld bc, 0x7f00 + PART2_DATA_BANK : out (c), c
ld hl, 0xbeef
ld (FOREVER_VARIABLE_SPACE + VARIABLE1_RELATIVE_POSITION + 0), hl
ld bc, 0x7f00 + 0xc0 : out (c), c
xor a
ld (FOREVER_VARIABLE_SPACE + VARIABLE2_RELATIVE_POSITION ), a
assert $<0x4000
ret
play_part
.init
; play with the data stored
DS_SELECT_BANK PART2_DATA_BANK
ld hl, (FOREVER_VARIABLE_SPACE + VARIABLE1_RELATIVE_POSITION + 0)
inc (hl)
ld hl, (FOREVER_VARIABLE_SPACE + VARIABLE1_RELATIVE_POSITION + 1)
dec (hl)
; deactivate screen display
ld bc, 0xbc00 + 1 : out (c), c
ld bc, 0xbd00 + 0 : out (c), c
DS_SELECT_BANK PART2_DATA_BANK
ld a, (FOREVER_VARIABLE_SPACE + VARIABLE2_RELATIVE_POSITION + 0)
inc a : and %11
ld (FOREVER_VARIABLE_SPACE + VARIABLE2_RELATIVE_POSITION+0 ), a
DS_SELECT_BANK 0xc0
DS_STOP_INTERRUPTED_MUSIC (void)
; we play the music a bit later than the vsync.
; lets hope this 1/2 hlts of difference do not impact the sound experience
.frame_loop
DS_WAIT_VSYNC (void)
; Get the persistent data
DS_SELECT_BANK PART2_DATA_BANK
ld a, (FOREVER_VARIABLE_SPACE + VARIABLE2_RELATIVE_POSITION+0)
push af
DS_SELECT_BANK 0xc0
pop af
; Select the color according to it
ld d, 0 : ld e, a
ld hl, .raster_table
add hl, de
ld a, (hl)
; play the music using a different color
halt : halt
ld bc, 0x7f10 : out (c), c
out (c), a
DS_PLAY_MUSIC (void)
ld bc, 0x7f10 : out (c), c
ld bc, 0x7f40 : out (c), c
halt
ld bc, 0x7f54 : out (c), c
; Only a limit amount of frames is allowed (init included)
; so we loop only if the system gives the authorization
DS_CHECK_IF_MUST_LEAVE (void)
jp nz, .frame_loop
.leave
; reactivate screen display
ld bc, 0xbc00 + 1 : out (c), c
ld bc, 0xbd00 + 80/2 : out (c), c
DS_INSTALL_INTERRUPTED_MUSIC (void)
DS_LAUNCH_NEXT_PART (void)
.raster_table
db 0x4b, 0x44, 0x45, 0x44
assert $< 0x4000
Quote from: St-BeidE(DE/GB) on Yesterday at 15:25My first thoughts where the same.Errr... damn.
I just have no tapedeck at all.
On the other hand, it forces me to build
an arduino solution...
Not sooo bad at least.
Stefan
Quote from: Targhan on Today at 18:18I didn't choose the CPC. It chose me.Yeah! Whole universe was create because God wanted to you got CPC.
Page created in 0.065 seconds with 19 queries.