Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org $6000 ; RANDOMIZE USR 24576
- ;set paper and border colours
- ld a,71 ;(white ink (7) on black paper (0) & bright (64)
- ld (23693),a
- ld a,1
- call 8859 ;set border colour
- ;set-up UDGs
- ld hl,udgs
- ld (23675),hl
- ;open main screen
- call 3503 ;Clear Screen & Open Channel 2
- ;initialise coordinates
- ld hl,20+(17*256)
- ld (plx),hl
- call basexy
- call splayr
- ;call draw
- ;call draw2 ;draw our UDGs
- call screen
- mloop equ $
- call basexy
- call wspace
- call mpu
- call basexy
- call wspace
- call mpd
- ;Key Press Checking
- ld bc,63486 ; keyboard row 1-5/joystick port 2.
- in a,(c) ; see what keys are pressed.
- rra ; outermost bit = key 1.
- push af ; remember the value.
- call nc,mpl ; it's being pressed, move left.
- pop af ; restore accumulator.
- rra ; next bit along (value 2) = key 2.
- push af ; remember the value.
- call nc,mpr ; being pressed, so move right.
- pop af ; restore accumulator.
- rra ; next bit (value 4) = key 3.
- push af ; remember the value.
- call nc,mpd ; being pressed, so return to BASIC
- pop af ; restore accumulator.
- rra ; next bit (value 8) reads key 4
- call nc,mpu ; being pressed, so move up.
- call basexy
- call splayr
- call mpu
- call basexy
- call splayr2
- call mpd
- halt
- jp mloop
- ;labels for key presses
- mpl ld hl,ply
- ld a,(hl)
- and a
- ret z
- ; now check that there isn't a mushroom in the way.
- ld bc,(plx) ; current coords.
- dec b ; look one square to the left
- call atadd ; get address of attribute at this position.
- ;dec (hl)
- cp 76; ladder is bright (64) + blue paper (1) + green ink (4).
- jp z,ladder; there was a ladder - we need to redraw it.
- dec (hl)
- ret
- mpr ld hl,ply
- ld a,(hl)
- cp 31
- ret z
- ; now check that there isn't a mushroom in the way.
- ld bc,(plx) ; current coords.
- inc b ; look 1 square to the right.
- call atadd ; get address of attribute at this position.
- cp 76 ; ladder is bright (64) + blue paper (1) + green ink (4).
- ret z ; there's a ladder - we can't move there.
- inc (hl)
- ret
- mpu ld hl,plx
- ld a,(hl)
- cp 4
- ret z
- ; now check that there isn't a mushroom in the way.
- ld bc,(plx) ; current coords.
- dec c ; look 1 square up.
- call atadd ; get address of attribute at this position.
- cp 68 ; mushrooms are bright (64) + green (4).
- ret z ; there's a mushroom - we can't move there.
- dec (hl)
- ret
- mpd ld hl,plx
- ld a,(hl)
- cp 21
- ret z
- ; now check that there isn't a mushroom in the way.
- ld bc,(plx) ; current coords.
- inc c ; look 1 square down.
- call atadd ; get address of attribute at this position.
- cp 68 ; mushrooms are bright (64) + green (4).
- ret z ; there's a mushroom - we can't move there.
- inc (hl)
- ret
- ; Calculate address of attribute for character at (dispx, dispy).
- atadd ld a,c ; vertical coordinate.
- rrca ; multiply by 32.
- rrca ; Shifting right with carry 3 times is
- rrca ; quicker than shifting left 5 times.
- ld e,a
- and 3
- add a,88 ; 88x256=address of attributes.
- ld d,a
- ld a,e
- and 224
- ld e,a
- ld a,b ; horizontal position.
- add a,e
- ld e,a ; de=address of attributes.
- ld a,(de)
- ret ; return with attribute in accumulator.
- ;Character Printing Routines
- basexy ld a,22
- rst 16
- ld a,(plx)
- rst 16
- ld a,(ply)
- rst 16
- ret
- splayr ld a,69
- ld (23695),a
- ld a,145
- rst 16
- ret
- splayr2 ld a,69
- ld (23695),a
- ld a,144
- rst 16
- ret
- wspace ld a,71
- ld (23695),a
- ld a,32
- rst 16
- ret
- ladder ld a,76
- ld (23695),a
- ld a,149
- rst 16
- ret
- ;draw the bunny characters at the bottom of the screen
- draw
- ld a,66
- ld (23695),a
- ld de,string
- ld bc,eostr-string
- call 8252
- ret
- ;draw the bunny characters at the bottom of the screen (facing the other direction) (Not currently called)
- draw4
- ld a,67
- ld (23695),a
- ld de,string4
- ld bc,eostr4-string4
- call 8252
- ret
- ;draw the UDGs
- draw2 ld a,67
- ld (23695),a
- ld de,string2
- ld bc,eostr2-string2
- call 8252
- ret
- screen
- ld de,string3
- ld bc,eostr3-string3
- call 8252
- ret
- plx defb 0
- ply defb 0
- ;UDG definitions
- udgs
- defb 112,154,159,61,93,117,124,56 ;UDG 144 (A)
- defb 8,62,93,157,21,116,119,7 ;UDG 145 (B)
- defb 14,89,249,188,186,174,62,28 ;UDG 146(C)
- defb 16,124,186,185,168,46,238,224 ;UDG 147(D)
- defb 239,239,239,0,254,254,254,0 ;UDG 148 (E)
- defb 126,66,126,66,126,66,126,66 ;UDG 149 (F)
- defb 255,255,255,252,240,240,224,224 ;UDG 150 (G)
- defb 255,231,255,0,0,0,0,0 ;UDG 151 (H)
- defb 255,255,255,63,15,15,7,7 ;UDG 152 (I)
- defb 255,255,183,221,107,170,84,0 ;UDG 153 (J)
- defb 60,126,219,255,195,195,126,60 ;UDG 154 (K)
- ;Printing the bunnies!
- string defb 22,20,30,144,22,21,30,145,22,20,28,144,22,21,28,145,22,20,26,144,22,21,26,145
- eostr equ $
- ;Printing the bunnies2!
- string4 defb 22,20,30,146,22,21,30,147,22,20,28,146,22,21,28,147,22,20,26,146,22,21,26,147
- eostr4 equ $
- ;Printing the UDGs!
- string2 defb 22,1,1,144,32,145,32,146,32,147,32,148,32,149,32,150,32,151,32,152,32,153,32,154
- eostr2 equ $
- string3 defb 16,2,17,6,22,3,8,148,148,148,148,148,148
- defb 22,3,14,148,148,148,148,148,148
- defb 22,3,26,148,148,148,148,148,148
- defb 22,6,1,148,148,148,148,148,148
- defb 22,9,6,148,148,148,148,148,148
- defb 22,9,12,148,148,148,148,148,148
- defb 22,9,20,148,148,148,148,148,148
- defb 22,15,6,148,148,148,148,148,148
- defb 22,15,12,148,148,148,148,148,148
- defb 22,15,2,148,148,148,148,148,148
- defb 16,3,17,6,22,6,20,148,148,148,148,148,148
- defb 22,6,26,148,148,148,148,148,148
- defb 22,12,0,148,148,148,148,148,148
- defb 22,12,6,148,148,148,148,148,148
- defb 22,12,9,148,148,148,148,148,148
- defb 22,12,20,148,148,148,148,148,148
- defb 22,12,26,148,148,148,148,148,148
- defb 22,15,23,148,148,148,148,148,148
- defb 22,15,26,148,148,148,148,148,148
- defb 22,18,0,148,148,148,148,148,148
- defb 22,18,6,148,148,148,148,148,148
- defb 22,18,10,148,148,148,148,148,148
- defb 22,18,18,148,148,148,148,148,148
- defb 22,18,26,148,148,148,148,148,148
- defb 16,4,17,1,22,3,20,153,153,153,153,153,153
- defb 22,3,22,153,153,153,153,153,153
- defb 22,6,7,153,153,153,153,153,153
- defb 22,15,9,153,153,153,153,153,153
- defb 16,5,22,9,15,150,151,151,151,152
- defb 22,18,9,150,151,151,151,152
- defb 22,18,21,150,151,151,151,152
- defb 16,4,17,1,22,3,27,149 ;ladder
- defb 22,4,27,149
- defb 22,5,27,149
- defb 22,6,10,149
- defb 22,7,10,149
- defb 22,8,10,149
- defb 22,6,23,149
- defb 22,7,23,149
- defb 22,8,23,149
- defb 22,9,7,149
- defb 22,10,7,149
- defb 22,11,7,149
- defb 22,12,12,149
- defb 22,13,12,149
- defb 22,14,12,149
- defb 22,12,24,149
- defb 22,13,24,149
- defb 22,14,24,149
- defb 22,15,4,149
- defb 22,16,4,149
- defb 22,17,4,149
- defb 22,15,29,149
- defb 22,16,29,149
- defb 22,17,29,149
- defb 22,18,8,149
- defb 22,19,8,149
- defb 22,20,8,149
- defb 22,18,20,149
- defb 22,19,20,149
- defb 22,20,20,149
- defb 16,2,17,6,22,21,0,148,148,148,148,148,148,148,148,148,148,16,3,148,148,148,148,148,148,148,148,148,148,16,2,148,148,148,148,148,148,148,148,148,148,148,148
- eostr3 equ $
- END $6000 ;Used to autostart the .tap file with Pasmo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement