├── Backgrounds └── empty.txt ├── Challenges ├── 6 │ ├── Adrian Brown - Tetris │ │ ├── Tetris.txt │ │ ├── build.bat │ │ ├── main.asm │ │ └── main.tap │ ├── Arcadiy Gobuzov - Cosmic Race │ │ ├── space_race.asm │ │ ├── space_race.bat │ │ ├── space_race.out │ │ ├── space_race.png │ │ └── space_race.sna │ ├── Dworkin Amberu - Gomoku │ │ ├── LICENSE │ │ ├── piskvorky.asm │ │ ├── piskvorky.bin │ │ └── piskvorky.z80 │ ├── Jim Bagley - Cars │ │ ├── a.bat │ │ ├── r.bat │ │ ├── sjasmplus.exe │ │ ├── test.asm │ │ ├── test.bin │ │ └── test.sna │ ├── Johan Koelman - Asteroid │ │ ├── asteroid.tap │ │ ├── asteroid_info.txt │ │ └── asteroid_src.asm │ ├── Johan Koelman - Snake │ │ ├── snake.tap │ │ └── snake.txt │ ├── John McManus - Flappy Bird │ │ ├── fbird7.asm │ │ ├── fbird7.bin │ │ └── fbird7.tap │ ├── Lucio Quintal - Lander V2 │ │ ├── LANDERV2.png │ │ ├── LANDERV2.tap │ │ └── versao18.asm │ ├── Mark Kirkby - Scramble │ │ ├── scramble.asm │ │ └── scramble.tap │ ├── Mike Daley - TrapIt │ │ ├── TrapIt.asm │ │ ├── TrapIt.bin │ │ ├── TrapIt.png │ │ ├── TrapIt.tap │ │ └── symbol.map │ ├── Peter Softhouse Turányi - Snake │ │ ├── snake256.TAP │ │ └── snake256.txt │ ├── Peter Softhouse Turányi - Space Invaders │ │ ├── source.txt │ │ └── spinv256.TAP │ └── Steve Wetherill - Infinite Runner │ │ ├── 256bytes.z80.sna │ │ └── blocky.asm ├── 20181006 │ ├── Compo #12.zip │ ├── Compo Size #12.zip │ ├── Screen1.scr │ ├── Screen2.scr │ ├── main.asm │ ├── main.tap │ └── symbol.map └── info.txt ├── Compression └── Tom Dalby │ └── LZF │ └── lzf.asm ├── Controls └── empty.txt ├── Drawing └── empty.txt ├── Examples └── Floating Point │ └── Line Segment Intersection │ └── main.asm ├── Maths └── empty.txt ├── Misc └── empty.txt ├── Screen └── Double-buffering │ └── polomint │ ├── generate_screen_table.asm │ └── transfer_buffer_screen_to_main_screen.asm ├── Sound └── empty.txt ├── Sprites └── empty.txt ├── Tutorials ├── Z80 Assembler Facebook.zip ├── Z80 Assembler Facebook │ ├── Part 1 │ │ ├── Part 1 - 1 │ │ │ ├── Z80.sln │ │ │ ├── Z80.vcxproj │ │ │ ├── Z80.vcxproj.filters │ │ │ ├── build.bat │ │ │ ├── clean.bat │ │ │ ├── main.asm │ │ │ ├── main.tap │ │ │ └── rebuild.bat │ │ ├── Part 1 - 2 │ │ │ ├── Z80.sln │ │ │ ├── Z80.vcxproj │ │ │ ├── Z80.vcxproj.filters │ │ │ ├── build.bat │ │ │ ├── clean.bat │ │ │ ├── main.asm │ │ │ ├── main.tap │ │ │ └── rebuild.bat │ │ ├── Part 1 - 3 │ │ │ ├── Z80.sln │ │ │ ├── Z80.vcxproj │ │ │ ├── Z80.vcxproj.filters │ │ │ ├── build.bat │ │ │ ├── clean.bat │ │ │ ├── main.asm │ │ │ ├── main.tap │ │ │ └── rebuild.bat │ │ ├── Part 1 - 4 │ │ │ ├── Z80.sln │ │ │ ├── Z80.vcxproj │ │ │ ├── Z80.vcxproj.filters │ │ │ ├── build.bat │ │ │ ├── clean.bat │ │ │ ├── main.asm │ │ │ ├── main.tap │ │ │ └── rebuild.bat │ │ ├── Part 1 - 5 │ │ │ ├── Z80.sln │ │ │ ├── Z80.vcxproj │ │ │ ├── Z80.vcxproj.filters │ │ │ ├── build.bat │ │ │ ├── clean.bat │ │ │ ├── main.asm │ │ │ ├── main.tap │ │ │ └── rebuild.bat │ │ └── Z80 Assembler - Part 1.pdf │ ├── Part 2 │ │ └── Z80 Assembler - Part 2 .pdf │ └── Part 3 │ │ ├── Part 3 - 1 │ │ ├── Z80.sln │ │ ├── Z80.vcxproj │ │ ├── Z80.vcxproj.filters │ │ ├── build.bat │ │ ├── clean.bat │ │ ├── main.asm │ │ └── rebuild.bat │ │ ├── Part 3 - 2 │ │ ├── Z80.sln │ │ ├── Z80.vcxproj │ │ ├── Z80.vcxproj.filters │ │ ├── build.bat │ │ ├── clean.bat │ │ ├── main.asm │ │ └── rebuild.bat │ │ ├── Z80 Assembler - Part 3.pdf │ │ └── Z80 Assembler - Part 3.zip ├── ZX Spectrum character set - Wikipedia.html └── ZX Spectrum character set - Wikipedia_files │ ├── 100px-ZXSpectrum48k.jpg │ ├── 16px-Folder_Hexagonal_Icon.svg.png │ ├── 16px-ZXSpectrum80.svg.png │ ├── 16px-ZXSpectrum81.svg.png │ ├── 16px-ZXSpectrum82.svg.png │ ├── 16px-ZXSpectrum83.svg.png │ ├── 16px-ZXSpectrum84.svg.png │ ├── 16px-ZXSpectrum85.svg.png │ ├── 16px-ZXSpectrum86.svg.png │ ├── 16px-ZXSpectrum87.svg.png │ ├── 16px-ZXSpectrum88.svg.png │ ├── 16px-ZXSpectrum89.svg.png │ ├── 16px-ZXSpectrum8a.svg.png │ ├── 16px-ZXSpectrum8b.svg.png │ ├── 16px-ZXSpectrum8c.svg.png │ ├── 16px-ZXSpectrum8d.svg.png │ ├── 16px-ZXSpectrum8e.svg.png │ ├── ZXSpectrum8f.svg.png │ ├── ZX_Spectrum_character_set.png │ ├── ZX_Spectrum_character_set_demo.png │ ├── load(1).php │ ├── load(2).php │ ├── load(3).php │ ├── load(4).php │ ├── load.php │ ├── poweredby_mediawiki_88x31.png │ └── wikimedia-button.png └── Utilities ├── empty.txt └── z80heap.asm /Backgrounds/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Backgrounds/empty.txt -------------------------------------------------------------------------------- /Challenges/20181006/Compo #12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/20181006/Compo #12.zip -------------------------------------------------------------------------------- /Challenges/20181006/Compo Size #12.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/20181006/Compo Size #12.zip -------------------------------------------------------------------------------- /Challenges/20181006/Screen1.scr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/20181006/Screen1.scr -------------------------------------------------------------------------------- /Challenges/20181006/Screen2.scr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/20181006/Screen2.scr -------------------------------------------------------------------------------- /Challenges/20181006/main.asm: -------------------------------------------------------------------------------- 1 | ;*********************************************************** 2 | ;* Size / Effect Coding #12 3 | ;* 4 | ;* Adrian Brown - adrian@apbcomputerservices.co.uk 5 | ;* 6 | ;*********************************************************** 7 | 8 | ORG 0c000h 9 | 10 | ;*********************************************************** 11 | 12 | Screen2: incbin "Screen2.scr" 13 | Screen1: incbin "Screen1.scr" 14 | 15 | ;*********************************************************** 16 | 17 | Start: 18 | ; Set border 19 | xor a 20 | out (254), a 21 | 22 | ; Copy the first screen to the physical screen 23 | ld de, 16384 24 | ld hl, Screen2 25 | ld bc, 6912 26 | ldir 27 | 28 | ; Call the routine we are measuring (or not in the effects version) 29 | call MyRoutine 30 | 31 | ; Wait a bit and go back 32 | ld b, 240 33 | PauseLoop: 34 | halt 35 | djnz PauseLoop 36 | 37 | jr Start 38 | 39 | ;*********************************************************** 40 | 41 | MyRoutine: 42 | ret 43 | 44 | ;*********************************************************** 45 | 46 | END Start -------------------------------------------------------------------------------- /Challenges/20181006/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/20181006/main.tap -------------------------------------------------------------------------------- /Challenges/20181006/symbol.map: -------------------------------------------------------------------------------- 1 | MyRoutine EQU 0F618H 2 | PauseLoop EQU 0F613H 3 | Screen1 EQU 0DB00H 4 | Screen2 EQU 0C000H 5 | Start EQU 0F600H 6 | -------------------------------------------------------------------------------- /Challenges/6/Adrian Brown - Tetris/Tetris.txt: -------------------------------------------------------------------------------- 1 | Controls 2 | O/P - Left and Right 3 | I - Rotate 4 | U - Drop -------------------------------------------------------------------------------- /Challenges/6/Adrian Brown - Tetris/build.bat: -------------------------------------------------------------------------------- 1 | ..\tools\pasmo.exe -1 --tapbas main.asm main.tap -------------------------------------------------------------------------------- /Challenges/6/Adrian Brown - Tetris/main.asm: -------------------------------------------------------------------------------- 1 | ;*********************************************************** 2 | ;* Size Coding #6 Entry 3 | ;* 4 | ;* Adrian Brown - adrian@apbcomputerservices.co.uk 5 | ;* 6 | ;*********************************************************** 7 | 8 | ORG 08000h 9 | 10 | ;*********************************************************** 11 | 12 | Start: 13 | ; Clear the screen (plus the printer buffer which will be used as variables) 14 | ld hl, $4000 15 | ld de, $4001 16 | ld (hl), l 17 | ld bc, &1bff 18 | ldir 19 | 20 | ; Draw the game border 21 | ld hl, $5829 22 | ld (hl), h 23 | ld de, $5834 24 | ld a, d 25 | ld (de), a 26 | ld e, $49 27 | ld bc, 32*21 28 | ldir 29 | ld b, 12 30 | _Board: 31 | ld (de), a 32 | inc e 33 | djnz _Board 34 | 35 | ;****************************************** 36 | ; See if we want to drop any rows down 37 | ;****************************************** 38 | CheckDrop: 39 | ld hl, $5aca 40 | ld c, 22 41 | _NextRow: 42 | ; See if this row is empty 43 | ld b, 10 44 | push hl 45 | _CheckRow: 46 | ld a, (hl) 47 | and a 48 | jr z, _NotFull 49 | inc l 50 | djnz _CheckRow 51 | 52 | ; We can now drop the blocks down 53 | ld a, c 54 | _NotFull: 55 | pop de 56 | ld hl, -32 57 | add hl, de 58 | 59 | ; Cheeky - use the flag from the djnz above the first time to exit and the jr nz below after that 60 | jr z, _DoNextRowCheck 61 | push hl 62 | ld c, 10 63 | ldir 64 | dec a 65 | jr nz, _NotFull 66 | 67 | pop hl 68 | jr CheckDrop 69 | 70 | _DoNextRowCheck: 71 | dec c 72 | jr nz, _NextRow 73 | 74 | ; We cant move down - redraw the piece where it was and check for falling 75 | _GetBlock: ld a, r 76 | and $38 77 | jr z, _GetBlock 78 | ld e, a 79 | rrca 80 | rrca 81 | rrca 82 | ld (BlockNum + 1), a 83 | 84 | ;****************************************** 85 | ; Set the starting position 86 | ;****************************************** 87 | NewBlockLoop: 88 | ld d, 1 89 | ld ixh, d 90 | ld hl, $582c ; (Block Starting Position) 91 | 92 | ; End of game 93 | call TestPiece 94 | jr nz, Start 95 | 96 | MainLoopResetFlag: 97 | ;****************************************** 98 | ; Now clear the z flag - remember the flags (or h as h will never be 0) 99 | ;****************************************** 100 | or h 101 | ex af, af' 102 | 103 | ;****************************************** 104 | ; Draw the block 105 | ;****************************************** 106 | MainLoop: 107 | ld a, e 108 | call DrawPiece 109 | 110 | ;****************************************** 111 | ; Wait a frame 112 | ;****************************************** 113 | halt 114 | 115 | ;****************************************** 116 | ; Check for drop 117 | ;****************************************** 118 | ex af, af' 119 | jr z, CheckDrop 120 | 121 | ;****************************************** 122 | ; Clear the block 123 | ;****************************************** 124 | call ClearPiece 125 | 126 | ; Store the current details 127 | push de 128 | push hl 129 | 130 | ;****************************************** 131 | ; Keyboard system 132 | ;****************************************** 133 | ld bc, $dffe 134 | in a, (c) 135 | bit 3, a 136 | jr z, _DroppingDown 137 | 138 | ; Debounce the keys 139 | cpl 140 | ld b, a 141 | xor ixl 142 | ld ixl, b 143 | and b 144 | 145 | rra 146 | jr nc, _NoRight 147 | inc hl 148 | _NoRight: 149 | rra 150 | jr nc, _NoLeft 151 | dec hl 152 | _NoLeft: 153 | rra 154 | jr nc, _NoRotate 155 | inc d 156 | _NoRotate: 157 | 158 | ;****************************************** 159 | ; Handle the delay 160 | ;****************************************** 161 | _DropDelay: dec ixh 162 | jr nz, _NotDropping 163 | _DroppingDown: 164 | ; Handle the dropping - restore HL/DE as we cant move to the side and drop 165 | ; else a block can get stuck on the side 166 | pop hl 167 | pop de 168 | push de 169 | push hl 170 | ld bc, 32 171 | add hl, bc 172 | ld ixh, 16 173 | _NotDropping: 174 | ; Check if it can be here 175 | ex af, af' 176 | call TestPiece 177 | 178 | ; Restore our old positions into the exx pairs 179 | exx 180 | pop hl 181 | pop de 182 | 183 | ; If we can move then start the loop again 184 | jr nz, MainLoop 185 | 186 | ; Get our new positions back 187 | exx 188 | 189 | jr MainLoopResetFlag 190 | 191 | ;*********************************************************** 192 | 193 | ClearPiece: 194 | xor a 195 | out (254), a 196 | DrawPiece: 197 | ld b, $77 ; OPCODE FOR ld (hl), a 198 | jr BlockFunction 199 | TestPiece: 200 | ld b, $b6 ; OPCODE FOR or (hl) 201 | xor a 202 | BlockFunction: 203 | push de 204 | push hl 205 | push af 206 | ld hl, NoData - 1 207 | ld (hl), b 208 | 209 | ;************************************ 210 | ; Get the block data 211 | ;************************************ 212 | ld hl, Blocks 213 | BlockNum: ld bc, 1 214 | add hl, bc 215 | 216 | ; Get rotations 217 | ld a, d 218 | and 3 219 | inc a 220 | rla 221 | ld c, a 222 | 223 | ; Get AE as the data byte shifted 4 224 | ld b, (hl) 225 | xor a 226 | rld 227 | ld e, (hl) 228 | ld (hl), b 229 | 230 | ;************************************ 231 | ; Rotate the block 232 | ;************************************ 233 | _Twiddle1: 234 | ld b, 8 235 | _Twiddle2: 236 | rl e 237 | rla 238 | rr h 239 | rl e 240 | rla 241 | rr l 242 | djnz _Twiddle2 243 | 244 | ex de, hl 245 | ld a, d 246 | dec c 247 | jr nz, _Twiddle1 248 | 249 | ;************************************ 250 | ; Get the position to draw the piece 251 | ;************************************ 252 | BlockPosition: 253 | pop af 254 | pop hl 255 | push hl 256 | 257 | ld b, 4 258 | _Loop1: 259 | push bc 260 | ld b, 4 261 | _Loop2: 262 | ; Wonder if we can link the get block data and this? 263 | sla e 264 | rl d 265 | jr nc, NoData 266 | ld (hl), a 267 | NoData: 268 | inc l 269 | djnz _Loop2 270 | 271 | ld c, 28 272 | add hl, bc 273 | 274 | pop bc 275 | djnz _Loop1 276 | 277 | pop hl 278 | pop de 279 | 280 | ; Do the test 281 | and a 282 | ret 283 | 284 | ;*********************************************************** 285 | ; DATA 286 | ;*********************************************************** 287 | 288 | Blocks: EQU $ - 1 289 | 290 | db %11000110 ; S 291 | db %00110110 ; Z 292 | db %01100110 ; O 293 | db %11101000 ; L 294 | db %11100010 ; J 295 | db %01001110 ; T 296 | db %11110000 ; I 297 | 298 | ;*********************************************************** 299 | ; VARIABLES 300 | ;*********************************************************** 301 | 302 | 303 | END 08000h -------------------------------------------------------------------------------- /Challenges/6/Adrian Brown - Tetris/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Adrian Brown - Tetris/main.tap -------------------------------------------------------------------------------- /Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.asm: -------------------------------------------------------------------------------- 1 | org 0x6000 2 | ;SPACE RACE by Arcadiy Gobuzov. Made for COMPO #6 www.facebook.com/groups/z80asm 3 | ;First (?) Spectrum multiplayer game in 256 bytes 4 | ; 5 | ; Control keys: 6 | ; - Start 7 | ; <1,2> RED ROCKET 8 | ; GREEN ROCKET 9 | ; 10 | ;tech details: we only draw in memory buffer [de00..ff3f] 11 | ;but on screen we see only 32x24 window 12 | ; 0123456789ABCDEF 13 | ;de00 14 | ;df00 15 | ;... 16 | ;e600 16 bytes XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 17 | ;e700 offscreen XX this window will on screen XX 18 | ;e800 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 19 | ;... 20 | ;fc00 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 21 | ;fd00 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 22 | ;fe00 23 | ;ff00 24 | STAR equ 255 ;/// colors 25 | ASTEROID equ 8 ; 26 | MAX_ASTEROIDS equ 217 ; 222-217 = 5 27 | startpoint: 28 | ; ld hl,end-startpoint ;temp to know size 29 | ei 30 | ld hl,0x5f5b ;hl,c as random seeds 31 | exx 32 | ; 33 | ; jr $ 34 | start_game: 35 | ld a,8 ; start energy 36 | ld (player1+2),a 37 | ld (player2+2),a 38 | ld a,221 ; one bad guy for begin 39 | ld (update+1),a 40 | ld d,0 41 | 42 | loop: ld bc,0xbffe 43 | in a,(c) 44 | rra 45 | jr nc,start_game 46 | 47 | clr_buf:xor a 48 | ld h,221 49 | clrloop:ld l,d ;first time 0; others 91 50 | ld (hl),a 51 | dec l 52 | jr nz,$-2 53 | inc h 54 | jr nz,clrloop 55 | 56 | ;object struct: [dy, y, dx, x, color] 57 | update: ld l,218 ; 256-objects ; 220 58 | updloop:ld h,221 59 | ; 60 | ; 1: update & check only y 61 | ld a,(hl) ; dy 62 | inc h 63 | add a,(hl) ; add y 64 | ld (hl),a 65 | ld d,a 66 | jr nz,update_normal 67 | ; 2: if offscreen, init new object: 68 | ; now h=222 69 | rand: exx 70 | ld a,h 71 | rra 72 | rrca 73 | rrca 74 | xor l 75 | rra 76 | rl c 77 | adc hl,hl 78 | exx 79 | ;//rand 80 | and 63 81 | ld e,a ; newx 82 | and 3 83 | rla ; a: [0,2,4,6] 84 | add a,h ; h=DE 85 | ld d,a ; newy 86 | ld a,l 87 | cp h ; DE: stars from XXDE..XXFF 88 | ld bc,0x100; dx = 0; dy = 1 89 | jr nc,init_star 90 | ;init_asteroid: 91 | res 0,e ; e= [0,2,4,6..62] 92 | inc c ; c=dx; +1 from left 93 | ld a,e ; 94 | cp 16 95 | jr c,asteroids 96 | dec c ; dx=0 central direction 97 | cp 48 98 | jr c,asteroids 99 | dec c ; c=-1 from right 100 | asteroids: 101 | ld a,ASTEROID 102 | jr init_object 103 | init_star: 104 | rra ;a-random 105 | ld a,STAR 106 | jr nc,$+3 107 | inc b ; randomly iy++ 108 | ;in: a: color [STAR, ASTEROID] 109 | ; bc: b=dy, c=dx 110 | ; de: d=newy, e=newx 111 | ;object struct: [dy, y, dx, x, color] 112 | init_object: 113 | dec h ; h=221 again 114 | ld (hl),b ; dy 115 | inc h 116 | ld (hl),d ; newy 117 | inc h 118 | ld (hl),c ; dx 119 | inc h 120 | ld (hl),e ; newx 121 | inc h 122 | ld (hl),a ; color 123 | ; 124 | update_normal: 125 | ld h,223 ; skip dy & y; d already = y 126 | ld a,(hl) ; dx 127 | inc h 128 | add a,(hl) 129 | ld (hl),a ; newx 130 | inc h 131 | ld e,a ; xcoor 132 | ld a,(hl) ; a-color 133 | ;de e-[0..63] x; d-[222..255] y; 134 | ;/// draw STAR or ASTEROID 135 | ld (de),a 136 | cp ASTEROID 137 | jr nz,nextspr 138 | inc e 139 | ld (de),a 140 | inc d 141 | ld (de),a 142 | dec e 143 | ld (de),a 144 | ; 145 | nextspr:inc l 146 | jr nz,updloop 147 | ; 148 | player1:ld de,0x1e ; D-energy; E-x coordinate 149 | ld bc,0xf750 ; B-keyport; C-color 150 | ld l,0x11 151 | call player 152 | ld (player1+1),de 153 | ; 154 | player2:ld de,0x21 ; D-energy; E-x coordinate 155 | ld bc,0xfd60 156 | ld l,0x2e 157 | call player 158 | ld (player2+1),de 159 | ; 160 | halt 161 | ; check time for increment asteroids 162 | dec xl 163 | jr nz,no_incr 164 | ld hl,update+1 ;ld hl,update 165 | ld a,(hl) 166 | cp MAX_ASTEROIDS ;ld a,(hl) 167 | jr z,no_incr ;cp N 168 | dec (hl) 169 | no_incr: 170 | moveonscr: 171 | ld de,22528 ;16 172 | ld h,222+8 173 | movloop:ld bc,32 ;! 174 | ld l,16 ;! 175 | ldir 176 | inc h 177 | jr nz,movloop 178 | ; 179 | jp loop 180 | 181 | ;in: de:lives,x; l:xbar; bc:keyport,color 182 | ;out: de:lives,x; 183 | player: inc d 184 | dec d 185 | ret z ; no lives return 186 | push bc ; store keyport 187 | ld b,d ; lives 188 | ld h,0xe7 ; second line in buffer 189 | 190 | barloop:ld (hl),c 191 | inc l 192 | bit 5,l ; right or left side of screen (32-center of buffer) 193 | jr z,barend 194 | dec l 195 | dec l 196 | barend: djnz barloop 197 | ;// draw rocket 198 | ld l,e ; xcoor 199 | ld h,0xfb ; ycoor 200 | ld (hl),c 201 | inc h 202 | inc l 203 | ld b,3 204 | check: ld a,(hl) ; collision detect here 205 | cp ASTEROID 206 | jr nz,draw 207 | dec d 208 | jr z,cont 209 | draw: ld (hl),c 210 | dec l 211 | djnz check 212 | ; 213 | cont: pop bc ; restore keyport 214 | ld c,$fe 215 | in a,(c) ; check 0 & 1 bits 216 | rra 217 | jr c,isright 218 | ld a,e 219 | cp 18 220 | ret z 221 | dec e 222 | ret 223 | isright: 224 | rra 225 | ret c 226 | ld a,e 227 | cp 45 ; right end x 228 | ret z 229 | inc e 230 | ret 231 | end: 232 | savesna "space_race.sna",startpoint -------------------------------------------------------------------------------- /Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.bat: -------------------------------------------------------------------------------- 1 | sjasmplus.exe -qmli. "space_race.asm" 2 | del "space_race.lst" 3 | pause -------------------------------------------------------------------------------- /Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.out -------------------------------------------------------------------------------- /Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.png -------------------------------------------------------------------------------- /Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.sna: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Arcadiy Gobuzov - Cosmic Race/space_race.sna -------------------------------------------------------------------------------- /Challenges/6/Dworkin Amberu - Gomoku/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Challenges/6/Dworkin Amberu - Gomoku/piskvorky.asm: -------------------------------------------------------------------------------- 1 | ; pasmo -d piskvorky.asm piskvorky.bin > test.asm ; ./bin2tap piskvorky.bin; ls -l piskvorky.bin 2 | 3 | PROGSTART EQU $C400 ; 50176 4 | ORG PROGSTART 5 | 6 | 7 | PLAYER_COLOR EQU 1*8 8 | AI_COLOR EQU 2*8 9 | MASK_COLOR EQU $38 10 | 11 | ; Start game from basic 12 | ; RANDOMIZE USR 50369 (0xC4C1) = progStart + 193 (+ $00C1) 13 | 14 | ; ---------------------------------------------------- 15 | ; Vstup: HL adresa kurzoru 16 | ; A priznaky posunu 17 | ; Vystup: pokud neni stisknuto FIRE tak zmeni jen registry AF,HL 18 | 19 | ; 4 3 2 1 0 20 | ; F(5) ↑(4) ↓(3) →(2) ←(1) Sinclair 1 (Sinclair left) 21 | MOVE: 22 | ; P_LEFT: 23 | PUSH BC 24 | PUSH DE 25 | 26 | LD BC,$001F 27 | RRCA ; nastavi carry 28 | LD D,A ; maska 29 | 30 | LD A,L 31 | SBC A,B 32 | ; P_RIGHT: 33 | SRL D ; nastavi carry 34 | ADC A,B 35 | 36 | AND C ; orezani do 0..31 pokud pretekl/podtekl 37 | XOR L 38 | AND C 39 | XOR L 40 | LD L,A 41 | 42 | ; P_DOWN: 43 | SRL D 44 | JR nc,P_UP 45 | ADC HL,BC 46 | P_UP: 47 | SRL D 48 | JR nc,P_FIRE 49 | SBC HL,BC 50 | P_FIRE: 51 | 52 | ; 57 0101 0111 +3 -> 5A 0101 1010 53 | ; 58 0101 1000 54 | ; 59 0101 1001 55 | ; 5A 0101 1010 56 | ; 5B 0101 1011 -3 -> 58 0101 1000 57 | 58 | LD A,H 59 | CP $57 60 | JR nz,P_NO_UNDERFLOW ; nepodtekl 61 | LD H,$5A ; Y max 62 | P_NO_UNDERFLOW: 63 | CP $5B 64 | JR nz,P_NO_OVERFLOW ; nepretekl 65 | LD H,$58 ; Y min 66 | P_NO_OVERFLOW: 67 | 68 | SRL D 69 | 70 | POP DE 71 | POP BC 72 | RET nc ; pokud neni stisknuto FIRE tak zmeni jen registry A,HL 73 | 74 | LD A,(HL) 75 | OR A 76 | RET nz ; neprepisujeme kameny 77 | LD (HL),PLAYER_COLOR ; PLAYER_COLOR = 2 78 | 79 | ; Zjednodusene nalezeni nejlepsiho tahu 80 | ; Find_best: 81 | LD HL,$5800 82 | LD C,L ; = 0 hodnota nejlepsi pozice, $FF = konec hry, existuje rada 5 kamenu 83 | PUSH HL ; souradnice nejlepsi pozice 84 | 85 | BRAIN_LOOP: 86 | 87 | 88 | ; ------------------------------------ 89 | ; Vystup: ixh 90 | ; Zmeni: IX, AF, DE 91 | ; COUNT_VALUE: 92 | LD IXH,0 ; vynulujeme hodnotu aktualni pozice 93 | LD DE,DATA_DIRECTION-1 94 | CV_LOOP: 95 | INC DE 96 | 97 | ; "zpetny chod" na okraj usecky v jejimz stredu je testovana pozice 98 | PUSH HL ; na zasobnik adresu zkoumane pozice, protoze ji budeme menit jak prochazime usecky 99 | LD B,5 100 | EL_TO_EDGE: 101 | LD A,(DE) 102 | CALL MOVE ; 103 | DJNZ EL_TO_EDGE 104 | 105 | INC DE 106 | ; prepnuti do stinovych registru 107 | EXX 108 | 109 | ; ------------------------------------ 110 | ; Vstup: shadow nothing, HL = cursor address, IYH value address, (DE) direction, C best value, HL on stack 111 | ; Zmeni: IX, AF, maybe C = $ff 112 | ; EXPLORE_LINE: 113 | 114 | ; inicializace smycky 115 | LD BC,$0900 ; B = citac, C = nalezeny kamen 116 | LD HL,$0010 ; hl hodnota souvisle rady, dame bonus pro ; dame bonus pro xxxx_ xxx._ xx.._ x..._ 117 | LD D,C ; = 0 hodnota linie 118 | LD E,C ; = 0 prazdnych 119 | LD IXL,C ; = 0 delka rady 120 | 121 | EL_LOOP: 122 | INC IXL ; zvedneme delku rady 123 | 124 | EXX 125 | ; navrat do "normalnich" registru 126 | LD A,(DE) ; nastaveni smeru 127 | CALL MOVE 128 | LD A,(HL) ; 129 | AND MASK_COLOR ; chceme jen barvu PAPER 130 | EXX 131 | JR nz,EL_FOUND_STONE 132 | 133 | ; --------------- 134 | ; EL_EMPTY: 135 | 136 | INC E ; prodlouzime radu prazdnych 137 | ADD HL,HL ; bonus za stred 138 | 139 | LD A,B ; 140 | CP 5 141 | JR z,EL_NEXT ; 142 | 143 | ADD HL,DE ; H = H + D, v L a E (pocet prazdnych) je "smeti" jehoz soucet nikdy nepretece pres bajt. Pokud se sejdou jednickove bity tak je L nizke. 144 | LD D,H 145 | 146 | LD HL,$0010 ; dostane bonus i pro priste 147 | JR EL_NEXT 148 | 149 | ; --------------- 150 | EL_FOUND_STONE: ; A je nenulove 151 | CP C ; shodne kameny? 152 | JR z,EL_IDENTIC 153 | 154 | INC C 155 | DEC C ; pokud tam byla 0 mame prvni kamen 156 | LD C,A ; ulozime novy kamen 157 | JR z,EL_IDENTIC ; prvni kamen, jinak by to blblo pri rade ._x. udelalo by to .x. 158 | 159 | ; --------------- 160 | ; EL_DIFFERENT: 161 | CALL ADD_VALUE_SERIES 162 | 163 | LD HL,$0008 164 | LD D,H 165 | 166 | INC E ; 167 | LD IXL,E ; delka nove rady = prazdnych + 1 kamen 168 | DEC E 169 | JR z,EL_IDENTIC 170 | 171 | ADD HL,HL ; dame bonus 2x protoze zacal prazdnym 172 | 173 | ; --------------- 174 | EL_IDENTIC: 175 | 176 | LD E,0 ; vymazeme radu prazdnych 177 | ADD HL,HL 178 | ADD HL,HL 179 | 180 | LD A,H 181 | CP $20 182 | JR c,EL_NEXT 183 | 184 | ; Nalezena rada 5 kamenu (asi) 185 | EX (SP),HL ; do HL adresa stredu zkoumane usecky 186 | LD A,(HL) 187 | OR A ; 188 | JR z,EL_5_NOT_FOUND 189 | ; Fakt nalezena 190 | SET 6,(HL) ; zesvetlime kamen 191 | EXX 192 | LD C,$FF ; Existuje_rada_5_kamenu = True 193 | EXX 194 | EL_5_NOT_FOUND: 195 | EX (SP),HL ; vratime jak to bylo 196 | 197 | EL_NEXT: 198 | DJNZ EL_LOOP 199 | 200 | ADD HL,HL ; dame bonus pro _xxxx _.xxx _..xx _...x 201 | CALL ADD_VALUE_SERIES 202 | 203 | ; end Explore_line -------------------------------------------- 204 | EXX 205 | 206 | POP HL ; obnovime pozici pred zkoumanim dalsiho smeru 207 | LD A,(DE) ; posledni je 1 208 | DEC A 209 | JR nz,CV_LOOP 210 | 211 | ; end Count_value ---------------------------------------------- 212 | 213 | LD A,(HL) 214 | OR A 215 | JR nz,B_NEXT ; pokud je na pozici kamen tak uz vse ignorujeme a deme dal, test na existenci rady 5 kamenu uz probehl 216 | 217 | LD A,IXH 218 | CP C ; porovname s nejlepsim 219 | JR c,B_NEXT ; pokud zname lepsi tak ignorujeme 220 | 221 | ; aktualne nejlepsi pozice 222 | POP DE ; vytahneme nejlepsi a zahodime 223 | PUSH HL ; ulozime lepsi 224 | LD C,A ; nejlepsi hodnota je ulozena v C 225 | B_NEXT: 226 | INC HL 227 | LD A,$5B ; $5800 + 3 * 256 = $5800 + $0300 228 | CP H 229 | JP nz,BRAIN_LOOP 230 | 231 | INC C ; Existuje rada 5 kamenu == $FF -> $00 232 | 233 | POP HL ; vytahneme nejlepsi ze zasobniku 234 | LD (HL), AI_COLOR ; 235 | 236 | RET nz ; 237 | LD (HL),C ; = 0, zmensime pravdepodobnost ze 1/50 vteriny bude videt pixel navic nez smazem obrazovku 238 | ; neni to korektni protoze teoreticky muzeme mit v HL uz obsazenou pozici pokud je $5800 uz rada peti 239 | ; propadnuti na Repeat_game 240 | 241 | 242 | ; -------------------------------- 243 | REPEAT_GAME: 244 | POP HL ; vytahneme nepouzitou adresu navratu pro ret 245 | 246 | NEW_GAME: 247 | ; clear screen 248 | LD HL,$4000 ; 3 249 | LD A,$5B ; 2 250 | CLEAR_LOOP: 251 | LD (HL),$00 ; 2 252 | INC HL ; 1 253 | CP H ; 1 254 | JR nz,CLEAR_LOOP ; 2 255 | 256 | ; umistime na stred a polozime kamen AI 257 | LD HL,$598F 258 | LD (HL),AI_COLOR 259 | 260 | READ_INPUT: 261 | LD E,(HL) 262 | LD (HL),$B8 ; 263 | 264 | LD BC,0XF7FE ; 265 | IN A,(C) ; 266 | CPL 267 | CP D 268 | LD D,A 269 | 270 | LD (HL),E ; vratim puvodni 271 | 272 | CALL nz,MOVE 273 | JR READ_INPUT 274 | 275 | 276 | ; ------------------------------- 277 | ADD_VALUE_SERIES: 278 | 279 | LD A,IXL ; delka rady 280 | CP $06 ; je tam pricten uz i odlisny kamen 281 | RET c ; pokud ma rada i s mezerama delku kratsi jak 5 tak nema zadnou hodnotu 282 | 283 | ADD HL,DE ; H = H + D, v L a E (pocet prazdnych) je "smeti" jehoz soucet nikdy nepretece pres bajt. Pokud se sejdou jednickove bity tak je L nizke. 284 | LD D,H 285 | ADD IX,DE ; IXH = IXH + D, IXL si zaneradime souctem puvodni delky rady s poctem jeho prazdnych poli, ale bude se menit 286 | 287 | RET 288 | 289 | 290 | ; 4 3 2 1 0 291 | ; F(5) ↑(4) ↓(3) →(2) ←(1) Sinclair 1 (Sinclair left) 292 | DATA_DIRECTION: 293 | DB 9,6,10,5,8,4,2,1 ; posledni je cislo 1! Pouzito zaroven jako zarazka 294 | -------------------------------------------------------------------------------- /Challenges/6/Dworkin Amberu - Gomoku/piskvorky.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Dworkin Amberu - Gomoku/piskvorky.bin -------------------------------------------------------------------------------- /Challenges/6/Dworkin Amberu - Gomoku/piskvorky.z80: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Dworkin Amberu - Gomoku/piskvorky.z80 -------------------------------------------------------------------------------- /Challenges/6/Jim Bagley - Cars/a.bat: -------------------------------------------------------------------------------- 1 | sjasmplus test.asm 2 | -------------------------------------------------------------------------------- /Challenges/6/Jim Bagley - Cars/r.bat: -------------------------------------------------------------------------------- 1 | test.sna 2 | -------------------------------------------------------------------------------- /Challenges/6/Jim Bagley - Cars/sjasmplus.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Jim Bagley - Cars/sjasmplus.exe -------------------------------------------------------------------------------- /Challenges/6/Jim Bagley - Cars/test.asm: -------------------------------------------------------------------------------- 1 | device zxspectrum48 2 | 3 | org $c000 4 | carx db 0 5 | roadx db 0 6 | gameframe db 0 7 | roadw db 0 8 | 9 | org $c100 10 | score db 0 11 | 12 | org $8000 13 | numbers 14 | db %11101011 ;0 15 | db %10101010 ;1 16 | db %11011011 ;2 17 | db %01110111 ;3 18 | db %10111101 ;4 19 | db %11100111 ;5 20 | db %10101111 ;6 21 | db %11010101 ;7 22 | db %11100111 ;8 23 | db %11110101 ;9 24 | 25 | start 26 | .menu 27 | ld a,%10111111 28 | in a,(254) 29 | rra 30 | jr c,.menu 31 | 32 | ld hl,carx 33 | ld (hl),15 ;carx 34 | inc l 35 | ld (hl),8 ;roadx 36 | ld l,roadw&255 37 | ld (hl),12 38 | xor a 39 | call cls 40 | 41 | ld hl,score 42 | .clrlp ld (hl),a 43 | inc l 44 | jr nz,.clrlp 45 | 46 | ld a,15 47 | ld (.lp+1),a 48 | 49 | .lp 50 | ld b,15 51 | .lop halt 52 | ld a,($c300) 53 | xor 24 54 | ld ($c300),a 55 | and 24 56 | out (254),a 57 | 58 | djnz .lop 59 | 60 | ld hl,$5ADF 61 | ld de,$5AFF 62 | ld bc,$2E0 63 | lddr 64 | ld hl,$5800 65 | ld bc,31 66 | ld a,4*8 67 | call fill 68 | ld a,(roadx) 69 | ld l,a 70 | ld bc,(roadw) 71 | ld b,0 72 | ld a,7 73 | call fill 74 | ld hl,(carx) 75 | ld h,$5a 76 | ld a,(hl) 77 | cp 4*8 78 | jp z,.menu 79 | ld (hl),2*8 80 | 81 | ld a,%11011111 82 | in a,(254) 83 | ld c,a 84 | ld a,l 85 | rr c 86 | jr c,.nr 87 | cp 31 88 | jr z,.nr 89 | inc l 90 | .nr rr c 91 | jr c,.nl 92 | or a 93 | jr z,.nl 94 | dec l 95 | .nl ld a,l 96 | ld (carx),a 97 | 98 | ld a,r 99 | ld b,a 100 | .del djnz .del 101 | 102 | ld a,r 103 | rlca 104 | rlca 105 | rlca 106 | and 1 107 | add a,a 108 | dec a 109 | ld h,a 110 | .ss 111 | ld bc,(roadx) 112 | ld a,31 113 | sub c 114 | ld b,a 115 | ld a,(roadx) 116 | add a,h 117 | or a 118 | jr z,.skp 119 | cp b 120 | jr z,.skp 121 | ld (roadx),a 122 | .skp 123 | 124 | ld hl,score+1 125 | ld a,9 126 | .sl inc (hl) 127 | cp (hl) 128 | jr nc,.ok 129 | ld (hl),0 130 | inc l 131 | jr nz,.sl 132 | .ok 133 | 134 | ld de,$4000 135 | ld hl,score+9 136 | .sc 137 | ld c,(hl) 138 | ld b,numbers/256 139 | ld a,(bc) 140 | ld b,4 141 | .bl ld c,a 142 | and $c0 143 | ld (de),a 144 | ld a,c 145 | rla 146 | rla 147 | inc d 148 | djnz .bl 149 | ld d,$40 150 | inc e 151 | 152 | dec l 153 | jr nz,.sc 154 | 155 | ld hl,gameframe 156 | inc (hl) 157 | jr nz,.skp1 158 | 159 | inc l ; roadw 160 | ld a,(hl) 161 | cp 4 162 | jr nz,.skp2 163 | ld a,(.lp+1) 164 | dec a 165 | jr z,.skp1 166 | ld (.lp+1),a 167 | db 62 168 | .skp2 169 | dec (hl) 170 | .skp1 171 | jp .lp 172 | 173 | cls ld hl,$5800 174 | ld bc,$2ff 175 | fill 176 | ld d,h 177 | ld e,l 178 | inc de 179 | ld (hl),a 180 | ldir 181 | ret 182 | 183 | 184 | last 185 | savebin "test.bin",$8000,last-$8000 186 | savesna "test.sna",start 187 | -------------------------------------------------------------------------------- /Challenges/6/Jim Bagley - Cars/test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Jim Bagley - Cars/test.bin -------------------------------------------------------------------------------- /Challenges/6/Jim Bagley - Cars/test.sna: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Jim Bagley - Cars/test.sna -------------------------------------------------------------------------------- /Challenges/6/Johan Koelman - Asteroid/asteroid.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Johan Koelman - Asteroid/asteroid.tap -------------------------------------------------------------------------------- /Challenges/6/Johan Koelman - Asteroid/asteroid_info.txt: -------------------------------------------------------------------------------- 1 | Asteroidbelt 2 | 3 | Travel your ship trough the asteroidbelt. 4 | 5 | Controls: 6 | 7 | (Re)Startgame : 5, T, Y, G, H, B, N 8 | Left: Q, A, Shift 9 | Right: W, S, Z 10 | 11 | 12 | 13 | Source: 14 | Controls in Tornado 15 | Sh.3 page down 16 | Sh.4 page up 17 | cursor 18 | E-cursor back to BASIC 19 | 20 | Technical info: 21 | Display of 32 lines on screen, 5 chardata + 1 blank 22 | Size of characterset: 60 bytes. 23 | A lot of reuse of registers. 24 | A-Result of IN is start of reading keyboard again. 25 | A-Result of keypress used to clear screen. 26 | A-Result of scroll is entry for reading ship-keys 27 | Hidden commands in other Z80 to save byte 28 | Carry always reset on calculating screen saves a byte 29 | Ship on top save a byte indicating location of ship 30 | Reverse order of numbers in characterset saves a byte in score-routine 31 | 8 bit horizontal movement, no bitposition needed, skipped from ROM-routine 32 | Position of SCORE in memory used to find final position. 33 | Printing done on line 3 to find end of byte in AND 7 -------------------------------------------------------------------------------- /Challenges/6/Johan Koelman - Asteroid/asteroid_src.asm: -------------------------------------------------------------------------------- 1 | ;Asteroidbelt 2 | 3 | ;Travel your ship trough the asteroidbelt. 4 | 5 | ;Controls: 6 | ;(Re)Startgame : 5, T, Y, G, H, B, N 7 | ;Left: Q, A, Shift 8 | ;Right: W, S, Z 9 | 10 | 11 | 12 | 13 | ? * TORNADO * 14 | ; order of nrs going down 15 | 16 | ORG 49152 17 | DUMP 49152 18 | 19 | ; characterset: ship, nr in reverse order, asteroid 20 | 21 | ship DEFB %00011000 ; ship 22 | DEFB %00100100 23 | DEFB %01000010 24 | DEFB %10011001 25 | DEFB %11100111 26 | 27 | DEFB %00111100 ; 9 28 | DEFB %00100100 29 | DEFB %00111100 30 | DEFB %00000100 31 | DEFB %00000100 32 | 33 | DEFB %00111100 ; 8 34 | DEFB %00100100 35 | DEFB %00111100 36 | DEFB %00100100 37 | DEFB %00111100 38 | 39 | DEFB %00111100 ; 7 40 | DEFB %00000100 41 | DEFB %00000100 42 | DEFB %00000100 43 | DEFB %00000100 44 | 45 | DEFB %00111100 ; 6 46 | DEFB %00100000 47 | DEFB %00111100 48 | DEFB %00100100 49 | DEFB %00111100 50 | 51 | DEFB %00111100 ; 5 52 | DEFB %00100000 53 | DEFB %00111100 54 | DEFB %00000100 55 | DEFB %00111100 56 | 57 | DEFB %00100100 ; 4 58 | DEFB %00100100 59 | DEFB %00111100 60 | DEFB %00000100 61 | DEFB %00000100 62 | 63 | DEFB %00111100 ; 3 64 | DEFB %00000100 65 | DEFB %00111100 66 | DEFB %00000100 67 | DEFB %00111100 68 | 69 | DEFB %00111100 ; 2 70 | DEFB %00000100 71 | DEFB %00111100 72 | DEFB %00100000 73 | DEFB %00111100 74 | 75 | DEFB %00000100 ; 1 76 | DEFB %00000100 77 | DEFB %00000100 78 | DEFB %00000100 79 | DEFB %00000100 80 | 81 | DEFB %00111100 ; 0 82 | DEFB %00100100 83 | DEFB %00100100 84 | DEFB %00100100 85 | DEFB %00111100 86 | 87 | rock DEFB %00101100 ; rock 88 | DEFB %01011010 89 | DEFB %10000010 90 | DEFB %10011001 91 | DEFB %01100110 92 | 93 | ; no game yet, but already 60 bytes "gone" 94 | 95 | score EQU 64000 ; somewhere in RAM #nn00 96 | 97 | ; the start of the game, first time just read A from any port 98 | 99 | wstart IN A,(254) ; 1st read can be skipped 100 | AND 16 ; start bit? 5 T Y G H B N 101 | JR NZ,wstart ; next read all rows but 6-0 102 | 103 | cls LD DE,23295 ; erase screen and attr 104 | LD HL,score+7 ; score in RAM and ATTR mask 105 | cls1 LD A,87 106 | CP D 107 | SBC A,A 108 | AND L 109 | LD (DE),A 110 | DEC DE 111 | BIT 6,D ; out of RAM 112 | JR NZ,cls1 ; only clear RAM-screen 113 | 114 | clscore DEC L 115 | LD (HL),10 ; set char "0" 116 | JR NZ,clscore ; clear all positions 117 | 118 | ; from above Z-flag set, from below possible collision 119 | ; placing test here makes a relative jump possible 120 | ; saves a byte in the code. 121 | 122 | scroll JR NZ,wstart ; test from dispship 123 | 124 | LD BC,#BF80 ; 191 lines, right side 125 | 126 | scr1 CALL field ; calculate screen 127 | EX DE,HL ; set destination 128 | PUSH BC ; save original linenumber 129 | LD A,B 130 | SUB 6 ; calculate from line 131 | onscreen LD B,A ; set from or use leftscreen 132 | CALL NC,field ; calculate from address 133 | LD BC,16 134 | LDIR ; copy the line down 135 | POP BC ; fetch original lines 136 | DJNZ scr1 ; do 'full' screen 137 | 138 | LD B,3 ; set star on top 139 | 140 | LD A,R ; better rnd than without 141 | rnd ADD A,0 ; add seed 142 | LD C,A 143 | RRCA 144 | RRCA 145 | RRCA 146 | XOR 31 147 | ADD A,C 148 | SBC A,255 149 | LD (rnd+1),A ; next seed 150 | OR 128 ; second half of screen only 151 | LD C,A 152 | 153 | LD E,rock-#C000 ; pointer to rock-char 154 | CALL disp ; AT B,C char from DE 155 | 156 | LD HL,score+7 ; unvisible number 157 | tens LD (HL),10 ; reset number to "0" 158 | DEC HL ; increase from prev. counter 159 | DEC (HL) ; "increase" score 160 | JR Z,tens ; do carry to next position 161 | 162 | LD L,6 ; point to visible score 163 | LD BC,#0330 ; AT for score 164 | scdisp LD A,(HL) ; fetch char 165 | ADD A,A ; x2 166 | ADD A,A ; x4 167 | ADD A,(HL) ; x5 168 | LD E,A ; index calculated 169 | PUSH HL ; save scorepointer 170 | CALL disp ; display character 171 | POP HL ; get scorepointer 172 | DEC HL ; next pointer 173 | LD A,C 174 | OUT (254),A ; engine sound 175 | SUB 8 ; due to -8 sound on/off 6x 176 | LD C,A 177 | JR NC,scdisp ; do all pointers 178 | 179 | 180 | ; XOR A ; not needed, use other keys 181 | IN A,(254) ; read QWERT, set above 182 | RRA ; test left key 183 | JR NC,xposship ; C holds -8 184 | LD C,8 ; set for right 185 | RRA ; test right key 186 | xposship LD A,200 ; get old xpos 187 | JR C,okmove ; false key only 188 | 189 | ADD A,C ; do move 190 | CP 127 ; test in range 191 | JR NC,okmove ; valid move 192 | SUB C ; undo move 193 | 194 | okmove LD (xposship+1),A ; save new xpos 195 | LD C,A ; set x for screen 196 | LD B,192-5 ; ypos of ship 197 | XOR A 198 | LD E,A ; charindex of ship 199 | DEC A ; 255 for test on collision 200 | prship CALL dispship ; show ship 201 | 202 | HALT ; some delay for gameplay 203 | HALT 204 | 205 | JR scroll ; Z from dispship = no coll. 206 | 207 | ; almost full copy of #22b0 from the ROM 208 | 209 | field LD A,B 210 | AND A ; reset needed from scroll 211 | RRA 212 | SCF 213 | RRA 214 | AND A 215 | RRA 216 | XOR B 217 | AND #F8 218 | XOR B 219 | LD H,A 220 | LD A,C 221 | RLCA 222 | RLCA 223 | RLCA 224 | XOR B 225 | AND #C7 226 | XOR B 227 | RLCA 228 | RLCA 229 | LD L,A 230 | RET 231 | 232 | disp XOR A ; no collisiontest 233 | dispship LD (col+1),A ; set collision yes/no 234 | CALL field ; screenaddress 235 | dloop LD D,#C0 ; character highbyte 236 | LD A,(DE) ; fetch char 237 | INC E ; point to next 238 | LD D,(HL) ; fetch screen 239 | LD (HL),A ; set char 240 | OR D ; something on screen 241 | XOR D 242 | SUB (HL) ; take off new value 243 | col AND 0 ; the actual test 244 | RET NZ ; collision ? 245 | nohit INC H ; next row on screen 246 | LD A,H 247 | AND 7 248 | JR NZ,dloop ; fill char 249 | RET ; print done 250 | -------------------------------------------------------------------------------- /Challenges/6/Johan Koelman - Snake/snake.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Johan Koelman - Snake/snake.tap -------------------------------------------------------------------------------- /Challenges/6/Johan Koelman - Snake/snake.txt: -------------------------------------------------------------------------------- 1 | ? * TORNADO * 2 | ; snake 3 | ; 48K memory needed, can fit in 16K but needs rewriting. 4 | ; therefore start also somewhere in uppermemory 5 | 6 | ORG 40000 7 | DUMP 40000 8 | 9 | wstart LD A,(IX+3) ; get winner colour 10 | OUT (254),A ; indicate winner 11 | 12 | ;start of game 13 | w4enter XOR A 14 | IN A,(254) ; read keyboard, all rows 15 | AND 16 ; start bit? 5 6 T Y G H B N 16 | JR NZ,w4enter ; wait startkey (not enter!) 17 | LD (trcnt+1),A ; reset tailcounter 18 | 19 | cls LD DE,23295 ; erase screen and attr 20 | cls1 LD (DE),A 21 | SET 7,D 22 | LD (DE),A ; clear track too 23 | RES 7,D 24 | DEC DE 25 | BIT 6,D ; out of RAM 26 | JR NZ,cls1 ; only clear RAM-screen 27 | LD H,A 28 | LD L,A 29 | LD (init),HL ; both start up 30 | 31 | startxy LD BC,#081C ; player 1 32 | LD E,C ; first "possible" move 33 | EXX ; alternate reg per player 34 | LD BC,#0808 ; player 2 35 | LD E,C ; idem 36 | 37 | gameloop LD IX,init ; set IX to player 1 38 | LD SP,60000 ; clear SP from below 39 | gameloop2 PUSH BC ; save xy 40 | INC B ; undo pos 0 41 | INC C ; undo pos 0 42 | LD HL,22528-1 ; calc attr 43 | ffield INC HL 44 | DEC C ; never first zero 45 | JR NZ,ffield ; x pos 46 | LD C,32 ; y = 32 * x 47 | DJNZ ffield 48 | LD A,(HL) ; fetch current position 49 | LD B,(IX+2) ; color of snake 50 | LD (HL),B ; set attr 51 | OR A 52 | JR NZ,wstart ; tailbyte, already used 53 | SET 7,H ; trackermemory +32K further 54 | LD (HL),E ; set index previous 55 | LD B,C ; always 32 56 | findtail DEC BC 57 | LD A,B 58 | OR C 59 | JR Z,wstart ; around on tail, failsave 60 | LD A,(HL) ; pointer to previous field 61 | SUB 33 ; pointer without shifting 62 | LD E,A ; pointer to E 63 | SBC A,A ; 0 or 255 64 | LD D,A ; set highbyte too 65 | ADD HL,DE ; calculate previous field 66 | LD A,(HL) 67 | OR A ; also reset of carry 68 | JR NZ,findtail ; no end of tail passed 69 | SBC HL,DE ; back to end of tail 70 | POP BC ; get xy 71 | PUSH HL ; save end for erase later 72 | 73 | 74 | ; do move 75 | LD D,254 ; upkey indicator 76 | DEFB #DD ; ld a,ixl 77 | LD A,L 78 | CP init*256/256 ; lowbyte of init 79 | JR NZ,keybpl2 ; own routine per player 80 | 81 | ; read keys player 1 82 | keybpl1 LD A,%11111011 ; Q-T 83 | IN A,(254) 84 | BIT 1,A 85 | JR Z,kup ; do up 86 | LD A,%11111101 ; A-G 87 | IN A,(254) 88 | RRA 89 | JR NC,kleft ; do left 90 | RRA 91 | JR NC,kright ; do right 92 | LD A,%11111110 ; SH-V 93 | OUT (254),A ; clear winner, set yellow 94 | IN A,(254) 95 | BIT 1,A 96 | JR downtest ; test at player2 saves 2 97 | 98 | ; read keys player 2 99 | keybpl2 LD A,%11011111 ; Y-P 100 | IN A,(254) 101 | BIT 2,A 102 | JR Z,kup ; do up 103 | LD A,%10111111 ; H-Enter 104 | IN A,(254) 105 | BIT 2,A 106 | JR Z,kright ; do right 107 | BIT 3,A 108 | JR Z,kleft ; do left 109 | LD A,%01111111 ; B-space 110 | IN A,(254) 111 | BIT 2,A 112 | downtest JR Z,kdown ; do down 113 | 114 | nokey INC D ; nokey, 255 115 | 116 | ; when rotated remains 255 117 | 118 | kright RLC D ; rotate to right bit 119 | kleft RLC D 120 | kdown RLC D 121 | kup LD A,D 122 | 123 | keyread LD D,A ; save old read from below 124 | RRA ; analyze read 125 | LD E,65 ; prev down 126 | JR NC,up ; do up 127 | RRA 128 | LD E,1 ; prev up 129 | JR NC,down ; do down 130 | RRA 131 | LD E,34 ; prev right 132 | JR NC,left ; do left 133 | RRA 134 | LD E,32 ; prev left 135 | LD A,(IX) ; fetch old move 136 | JR C,keyread ; false key 137 | right INC C 138 | DEFB 62 ; left hidden in LD A,N 139 | left DEC C 140 | DEFB 62 ; up hidden in LD A,N 141 | up DEC B 142 | DEFB 62 ; down hidden in LD A,N 143 | down INC B 144 | LD A,B ; out of screen 145 | CP 24 146 | jrdead JP NC,wstart ; dead, below 1 byte saved 147 | LD A,C 148 | CP 32 149 | JR NC,jrdead ; out of screen, dead 150 | 151 | ; a valid move is possible 152 | setmove LD A,D ; fetch the valid move 153 | LD (IX),A ; set as next old move 154 | 155 | EXX ; other player registers 156 | DEFB #DD ; ld a,ixl 157 | LD A,L 158 | CP init*256/256 159 | INC IX ; set IX to player 2 160 | JP Z,gameloop2 ; do both players 161 | 162 | HALT ; now some delay 163 | HALT ; before erasing tails 164 | HALT 165 | 166 | trcnt LD A,0 ; step counter 167 | INC A 168 | AND 31 169 | LD (trcnt+1),A 170 | POP HL ; fetch first from stack 171 | JR Z,noerase 172 | 173 | erase XOR A 174 | LD (HL),A ; reset tracker 175 | RES 7,H 176 | LD (HL),A ; erase visible tail 177 | POP HL ; fetch second 178 | LD (HL),A 179 | RES 7,H 180 | LD (HL),A ; erase tail 2 181 | 182 | noerase JP gameloop ; playon, clear stack 183 | 184 | init DEFB 0,0 ; start movement 185 | DEFB 36,45 ; color of snake 186 | DEFB 36 ; winner/loser with previous 187 | 188 | ; init can be set here too, for data it would save 2 bytes 189 | ; since program will clear it. But game is in range. -------------------------------------------------------------------------------- /Challenges/6/John McManus - Flappy Bird/fbird7.asm: -------------------------------------------------------------------------------- 1 | ccc; ----------------------------------------------------------------------------- 2 | ; Name: fbird 3 | ; Author: John McManus 4 | ; Started: 19th May 2016 5 | ; Finished: 6 | ; 7 | ; 8 | ; This is an entry for the 256 bytes game competition #6 on the Z80 Assembly programming 9 | ; on the ZX Spectrum Facebook Group https://www.facebook.com/groups/z80asm/ 10 | org 40000 11 | 12 | ;***** Constants ***** 13 | K_ATTR_ADDR equ 0x5800 ; 22528 14 | K_ATTR_BUFFER equ 0XAF00 ; 44800 15 | K_SCORE_ATT equ 45738 16 | K_GRAVITY equ 0x00AFF 17 | K_BIRDX equ 0 18 | K_BIRDY equ 5 19 | K_BLANK equ 0 20 | K_BIRD equ 32 21 | K_WALL equ 24 22 | K_SCORE equ 8 23 | K_COLDB equ 0xA028 ; 41000 24 | K_XSTART equ 0 25 | K_XGAP equ 8 26 | K_ENDCOL equ 31 27 | ; **** Variables ***** 28 | bird_x DEFB K_BIRDX ; x position will be constant 29 | bird_y DEFB K_BIRDY ; x position will be constant 30 | score DEFB 0x01; 31 | gravcount DEFW K_GRAVITY 32 | lastkey DEFB 0 33 | ;flapdelay defb 255 34 | ;******************************************************** 35 | call builddbnew 36 | mainloop 37 | call keypress ; if key pressed move bird up 38 | call chkgrav ; counts down gravity function. all updates are based 39 | ret z ; end of game 40 | jr mainloop ; program loop 41 | 42 | updateloop ; this does all the update called from delay function 43 | call applygravity 44 | ;call clrbuffer 45 | ;call drawcolumns 46 | ; call updatescore 47 | call refreshScreen 48 | call mvcl 49 | 50 | ret 51 | 52 | ; ***************** Subroutines ----re organised to reduce number of calls 53 | ;check for key press 54 | 55 | keypress 56 | ld a , (lastkey) 57 | ld b, a 58 | xor a 59 | IN A,(254) ; 60 | and 31 61 | cp b 62 | ret z 63 | ;statechange 64 | ld (lastkey), a 65 | 66 | flap 67 | ld hl, bird_y 68 | dec (hl) 69 | ;dec (hl) 70 | endflap 71 | ret 72 | 73 | ; decrements garvity count until zero (just a timer) 74 | ; trigger the rest of the game movements 75 | chkgrav LD BC,(gravcount) 76 | DEC BC 77 | LD A,C 78 | OR B 79 | JR NZ, SAVGRAV 80 | ;reset gravcount 81 | LD BC, K_GRAVITY 82 | ;LD (gravcount), BC 83 | call SAVGRAV 84 | call updateloop 85 | RET 86 | SAVGRAV 87 | LD (gravcount), BC 88 | RET 89 | 90 | ;move the bird down - should really make if 23 stop game 91 | applygravity 92 | ;ld a,(bird_y) 93 | ; cp 22 94 | ;jp Z, endgrav 95 | ld hl, bird_y 96 | inc (hl) 97 | endgrav 98 | ; ret 99 | 100 | clrbuffer 101 | ld de, K_ATTR_BUFFER+1 102 | ld hl, K_ATTR_BUFFER 103 | ld (hl), 0 104 | ld bc ,767 105 | ldir 106 | 107 | ;ld de, K_ATTR_BUFFER+1 108 | ;ld hl, K_ATTR_BUFFER 109 | ;ld (hl), K_WALL 110 | ;ld bc ,31 111 | 112 | ;ldir 113 | 114 | ;ld de, K_ATTR_BUFFER+705 115 | ;ld hl, K_ATTR_BUFFER+704 116 | ;ld (hl), K_WALL 117 | ;ld bc ,31 118 | ;ldir 119 | 120 | ;; put bird back on 121 | 122 | ld de ,(bird_x) 123 | ld a, K_BIRD 124 | call drawpoint 125 | ;ret 126 | 127 | 128 | 129 | drawcolumns 130 | ld ix , K_COLDB 131 | ld b, 0 132 | getnext 133 | ;d,e hold x,y for drawpoint routine 134 | 135 | ld d, (ix) 136 | inc ix 137 | ld e, (ix) 138 | ;ld d ,(ix) 139 | ;push hl 140 | ld a, K_WALL ; holds the attrib colour for drawpoint 141 | call drawpoint 142 | ;pop hl 143 | inc ix 144 | ld a ,(ix) 145 | cp 255 ; looking for end of DB 146 | jr NZ , getnext 147 | ret 148 | 149 | mvcl 150 | ld hl, K_COLDB+1 151 | mvnxt 152 | ld a, 255 153 | cp (hl) 154 | jr z , endmvcl 155 | dec (hl) 156 | cp (hl) 157 | jr Z , wrap 158 | jr nowrap 159 | wrap 160 | ;ok we are on 0 check if the bird is on 161 | ld b,1 162 | ld (hl), 31 163 | 164 | dec hl ; move to y position 165 | ld a,(bird_y) 166 | cp (hl) 167 | jr z, kill 168 | inc hl 169 | nowrap 170 | inc hl 171 | inc hl 172 | jr mvnxt 173 | endmvcl 174 | ld a,1 175 | xor b 176 | jp nz , donemv 177 | 178 | ld hl, score 179 | inc (hl) 180 | ; 181 | 182 | donemv 183 | 184 | ret 185 | 186 | kill 187 | xor a 188 | ret 189 | 190 | 191 | ;de = x,y 192 | ;a = attrib setting 193 | drawpoint 194 | push af 195 | LD a, d 196 | sra a 197 | sra a 198 | sra a 199 | add a, 0xAF 200 | ld h,a 201 | ld a,d 202 | and 7 203 | RRCA 204 | RRCA 205 | RRCA 206 | ADD a,e 207 | LD L,A 208 | pop af 209 | ld (hl), a 210 | ret 211 | 212 | 213 | builddbnew 214 | ;db format is y,x - 215 | ; try and build from the bottom up 216 | ; b = length of screen 217 | 218 | ld c, 5 ; number of columns 219 | ld d, 0 220 | ;xor d 221 | ;xor d 222 | ;ld d, K_XGAP 223 | ld hl, K_COLDB 224 | 225 | newcol 226 | ld b, 22 ; number of rows and y value 227 | ;ld a, 15 ; start the gap at 15 228 | 229 | ld a, 6 230 | add a,d 231 | ld d,a 232 | 233 | ; halt 234 | ; halt 235 | ; halt 236 | LD A, R 237 | ;halt 238 | ;ld a,(Rand8+1) 239 | and %00001111 240 | or %00001000 241 | ;inc d 242 | ;inc d 243 | ;inc d 244 | ;inc d 245 | ;inc d 246 | ;inc d 247 | 248 | ldxy 249 | cp b 250 | jp z , skipgap 251 | ld (hl), b 252 | inc hl 253 | ld (hl), d 254 | inc hl 255 | jp nextrow 256 | skipgap 257 | rr b 258 | ;dec b 259 | ;dec b 260 | ;dec b 261 | nextrow 262 | djnz ldxy 263 | ;if b wraps from z to 255 jump to col done 264 | ;jp P, coldone 265 | ld (hl), b 266 | inc hl 267 | ld (hl), d 268 | inc hl 269 | 270 | dec c 271 | xor a 272 | cp c 273 | jp nz, newcol 274 | 275 | 276 | ld (hl), 255 277 | inc hl 278 | ld (hl), 255 279 | 280 | ret 281 | 282 | ;updatescore 283 | ; ld hl, K_ATTR_BUFFER+768-32 284 | ; ld a,(score) 285 | ; ld b, a 286 | ; ld b,10 287 | ; ld b,1 288 | ; ld a, K_BIRD 289 | ;more 290 | ; ld (hl),K_SCORE 291 | ; inc hl 292 | ; djnz more 293 | 294 | refreshScreen 295 | ld de, K_ATTR_ADDR 296 | ld hl, K_ATTR_BUFFER 297 | ld bc, 768 298 | ldir 299 | ret 300 | ;ret 301 | 302 | 303 | 304 | 305 | 306 | 307 | -------------------------------------------------------------------------------- /Challenges/6/John McManus - Flappy Bird/fbird7.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/John McManus - Flappy Bird/fbird7.bin -------------------------------------------------------------------------------- /Challenges/6/John McManus - Flappy Bird/fbird7.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/John McManus - Flappy Bird/fbird7.tap -------------------------------------------------------------------------------- /Challenges/6/Lucio Quintal - Lander V2/LANDERV2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Lucio Quintal - Lander V2/LANDERV2.png -------------------------------------------------------------------------------- /Challenges/6/Lucio Quintal - Lander V2/LANDERV2.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Lucio Quintal - Lander V2/LANDERV2.tap -------------------------------------------------------------------------------- /Challenges/6/Lucio Quintal - Lander V2/versao18.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Challenges/6/Lucio Quintal - Lander V2/versao18.asm -------------------------------------------------------------------------------- /Challenges/6/Mark Kirkby - Scramble/scramble.asm: -------------------------------------------------------------------------------- 1 | org 08000h 2 | 3 | 4 | waitingMoveUpBit EQU 0 5 | moveUpBit EQU 1 6 | enemyBit EQU 2 7 | flashBit EQU 7 8 | 9 | clearBit EQU 6 10 | 11 | paper EQU 8 12 | 13 | siloColourBit EQU 3 14 | rocketColourBit EQU 4 15 | landColourBit EQU 5 16 | tunnelColour1 EQU 0 17 | playerFrontColour1 EQU 7 18 | playerBehindColour1 EQU 6 19 | bulletColour EQU 5 20 | 21 | landAttr EQU ((1< attribs 262 | ; de -> attribs+1 263 | ; bc = length of color file - 1 264 | ; preserves 265 | ; af 266 | ; af', bc', de', hl' 267 | 268 | LD hl,attribs 269 | LD de,attribs+1 270 | LD bc,attribs_size-1 271 | RET 272 | 273 | 274 | -------------------------------------------------------------------------------- /Challenges/info.txt: -------------------------------------------------------------------------------- 1 | # :p 2 | -------------------------------------------------------------------------------- /Compression/Tom Dalby/LZF/lzf.asm: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; ======================================================================== 3 | ;; LZF compressor for the z80 microprocessor (217bytes) 4 | ;; input hl=memory to compress 5 | ;; de=size of memory to compress 6 | ;; bc=place to store the compression 7 | ;; uses simple greedy parsing due to limitations of the machine 8 | ;; slow to compress due to scanning of full dictionary every time 9 | ;; ======================================================================== 10 | _lzf: 11 | ld (_lzf_start+1),hl ; 16t - put compression start into later code 12 | add hl,de ; 11t - resets the carry flag as well 13 | ld (_lzf_end1+1),hl ; 16t - put end into later code for checks 14 | ld (_lzf_end2+1),hl ; 16t 15 | ld (_lzf_end3+1),hl ; 16t 16 | sbc hl,de ; 15t - restore hl 17 | ld d,b ; 4t 18 | ld e,c ; 4t 19 | inc de ; 6t - de=bc+1, bc=control byte, de=byte store 20 | call _lzf005 ; 17t 21 | ld a,(bc) ; 7t - get last control byte 22 | cp 255 ; 7t - if control byte already $ff then end marker in place already 23 | ret z ; 11/5t 24 | ld b,d ; 4t 25 | ld c,e ; 4t - bc=de 26 | ld a,255 ; 7t - if not put one in 27 | ld (de),a ; 7t 28 | ret ; 10t 29 | ;; 30 | ;; sort out the control byte for literals 31 | _lzf000: 32 | ld a,(bc) ; 7t - get control byte 33 | inc a ; 4t - add one to counter 34 | cp 32 ; 7t - at max? 35 | jr nz,_lzf010 ; 12/7t - if at max start a new control byte 36 | ld b,d ; 4t 37 | ld c,e ; 4t - move bc to current byte store pos 38 | inc de ; 6t - +1 to move to byte store past control byte 39 | _lzf005: 40 | xor a ; 4t - reset a to 0 which is 1 literal, 0=1 literal 41 | _lzf010: 42 | ld (bc),a ; 7t - put back in mem 43 | ;; 44 | ;; put literal in store 45 | ld a,(hl) ; 7t - get screen byte 46 | ld (de),a ; 7t - load into byte store 47 | inc de ; 6t - next mem 48 | ;; 49 | ;; set-up search starting pos 50 | _lzf020: 51 | inc hl ; 6t - move start scr check pos on one 52 | ;; 53 | ;; check if at the end 54 | push de ; 11t 55 | _lzf_end1: 56 | ld de,0000 ; 10t - end 57 | xor a ; 4t - reset carry and reset a 58 | sbc hl,de ; 15t - this will set the zero flag 59 | add hl,de ; 11t - restore hl and leave zero flag alone 60 | pop de ; 10t 61 | ret z ; 11/5t 62 | ;; 63 | ;; check for match, hl=start scr check pos 64 | push bc ; 11t - preserve control store pointer (sp=control store) 65 | push de ; 11t - preserve byte store pointer (sp=byte store) 66 | ;; 67 | ;; 68 | push hl ; 11t - store hl 69 | ld de,7936 ; 10t - max size of offset is 7936 70 | or a ; 4t - clear carry 71 | sbc hl,de ; 15t - get new dictionary start 72 | ;; 73 | ;; check if new dictionary start < lowest start then shift up to lowest start 74 | _lzf_start: 75 | ld de,0000 ; 10t - lowest start possible 76 | jr c,_lzf025 ; 12/7t - if carry from previous subtraction then gone below zero so just use lowest 77 | sbc hl,de ; 15t - if dictionary start < lowest start then use lowest start 78 | jr c,_lzf025 ; 12/7t - if a carry then use lowest start instead 79 | add hl,de ; 11t - if no carry then use new dictionary start 80 | ex de,hl ; 4t - de now hl 81 | _lzf025: 82 | pop hl ; 10t 83 | ld b,a ; 4t - clear max length 84 | ;; 85 | ;; bc=offset, de=dictionary start, hl=start scr check pos 86 | _lzf030: 87 | ld c,a ; 4t - clear length counter 88 | push hl ; 11t - store start scr check pos (sp=start scr check pos) 89 | push de ; 11t - store dictionary start (sp=dictionary start) 90 | ;; 91 | ;; do the check 92 | _lzf040: 93 | ld a,(de) ; 7t - get byte from dictionary 94 | cp (hl) ; 7t - check against scr check pos 95 | jr nz,_lzf070 ; 12/7t - jump if byte mismatch 96 | ;; 97 | ;; match found 98 | inc c ; 4t - increase counter 99 | jr nz,_lzf060 ; 12/7t - if length=0, then at maximum of 256 so stop searching 100 | ;; 101 | ;; small speed up as if at maximum no better match could possibly be found, exit keeping hl as last scr check pos 102 | ld a,c ; 4t 103 | ld (_lzf120+1),hl ; 16t - store end of last match pos 104 | pop de ; 10t - bring back current dictionary start into de (sp=start scr check pos) 105 | pop hl ; 10t - bring back start scr check pos into hl (sp=byte store) 106 | jr _lzf115 ; 12t - jump into match>3 code 107 | ;; 108 | ;; keep checking 109 | _lzf060: 110 | inc de ; 6t - move to next dictionary position 111 | inc hl ; 6t - next scr pos to check 112 | ;; 113 | ;; if end of screen stop checking 114 | push de ; 11t 115 | _lzf_end2: 116 | ld de,0000 ; 10t 117 | xor a ; 4t - reset carry 118 | sbc hl,de ; 15t - this will set the zero flag 119 | add hl,de ; 11t - restore hl and leave zero flag alone 120 | pop de ; 10t - restore de 121 | jr nz,_lzf040 ; 12t - if not at end just loop 122 | ;; 123 | ;; no match or end of screen 124 | _lzf070: 125 | pop de ; 10t - bring back current dictionary start (sp=start scr check pos) 126 | ld a,c ; 4t - length into a for check 127 | cp 3 ; 7t - is match >=minsize 128 | jr c,_lzf080 ; 12/7t - new then do nothing 134 | ld b,c ; 4t - store new max in b 135 | ld (_lzf110+1),de ; 20t - store dictionary start into later code 136 | dec hl ; 6t - back one as last wasn't a match 137 | ld (_lzf120+1),hl ; 16t - store end of last match pos 138 | ;; 139 | ;; if end of last match=end then stop 140 | push de ; 11t 141 | _lzf_end3: 142 | ld de,0000 ; 10t 143 | dec de ; 6t - at the end? 144 | or a ; 4t - reset carry 145 | sbc hl,de ; 15t - this will set the zero flag 146 | add hl,de ; 11t - restore hl and leave zero flag alone 147 | pop de ; 10t 148 | jr nz,_lzf080 ; 12/7t - if not at end stop 149 | pop hl ; 10t 150 | ld a,b ; 4t - a=last max 151 | jr _lzf115 ; 12t 152 | ;; 153 | ;; keep moving the window along till checked all positions for optimal pattern size 154 | _lzf080: 155 | pop hl ; 10t - bring back start scr check pos (sp=byte store) 156 | inc de ; 6t - shift dictionary window along one 157 | ;; 158 | ;; check if caught up 159 | xor a ; 4t - clear carry & next counter 160 | sbc hl,de ; 15t 161 | add hl,de ; 11t - restore hl 162 | jr nz,_lzf030 ; 12/7t (6b,42t) 163 | ;; 164 | ;; dictionary has caught up with scr check pos so bring back max and check if there was a large enough match 165 | ld a,b ; 4t - max length 166 | or a ; 4t - has the match routine return >0? 167 | jr nz,_lzf110 ; 12/7t - if >minsize then a match, otherwise just copy 168 | _lzf160: 169 | pop de ; 10t - bring back byte store (sp=control store) 170 | pop bc ; 10t - bring back bit store (sp clear) 171 | jp _lzf000 ; 10t - store new literal, no need to clear max as already 0, hl=start scr pos 172 | ;; 173 | ;; store pattern routine a=length 174 | _lzf110: 175 | ld de,0000 ; 10t - de=dictionary start, hl=start scr check pos 176 | _lzf115: 177 | and a ; 4t - clear carry 178 | sbc hl,de ; 15t - hl-de 179 | ld b,h ; 4t 180 | ld c,l ; 4t - bc now the offset 181 | dec bc ; 6t - offset-1 182 | pop de ; 10t - bring back byte store into de (sp=control store) 183 | pop hl ; 10t - bring back control store into hl (sp=free) 184 | ex af,af' ; 4t - alta 185 | ld a,(hl) ; 7t - get control store byte 186 | cp 255 ; 7t - is it clear? 187 | jr z,_lzf180 ; 12/7t - if 255 then free otherwise already in use for literals need to move to byte store 188 | ld h,d ; 4t 189 | ld l,e ; 4t - move hl to current byte store pos 190 | inc de ; 6t - move de to next byte as before 191 | _lzf180: 192 | ex af,af' ; 4t - norma 193 | sub 2 ; 7t - 3->1, 9->7 194 | cp 7 ; 7t - if >=7 then need an extra byte 195 | jr c,_lzf190 ; 12/7t - no need for extra byte 196 | sub 7 ; 7t - take away 7 197 | ld (de),a ; 7t - load length-7 into de 198 | inc de ; 6t - move de on one 199 | ld a,7 ; 7t - set to 7 for next part 200 | _lzf190: 201 | rrca ; 4t 202 | rrca ; 4t 203 | rrca ; 4t - move length to last 3bits 204 | add a,b ; 7t - bring in offset hi byte 205 | ld (hl),a ; 7t - put into hl 206 | ld a,c ; 4t - offset low byte 207 | ld (de),a ; 7t - load offset low byte 208 | inc de ; 6t 209 | ld b,d ; 4t 210 | ld c,e ; 4t - move control store to new byte store pos 211 | inc de ; 6t - de=byte store, bc=control store 212 | _lzf120: 213 | ld hl,0000 ; 10t - hl=last scr check pos loaded from elsewhere 214 | ;; 215 | ;; clear max & new control bit 216 | ld a,255 ; 7t 217 | ld (bc),a ; 7t - clear next control byte 218 | jp _lzf020 ; 10t - back up to top and onto next using last scr check pos as next start 219 | _lzfend: -------------------------------------------------------------------------------- /Controls/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Controls/empty.txt -------------------------------------------------------------------------------- /Drawing/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Drawing/empty.txt -------------------------------------------------------------------------------- /Examples/Floating Point/Line Segment Intersection/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Line Intesection by Adrian Brown 4 | ; 5 | ;----------------------------------------------------------- 6 | ; NOTES: 7 | ; Remember 0,0 is the bottom left of the screen! 8 | ; Based on the line segment intersection code from 9 | ; http://paulbourke.net/geometry/pointlineplane/ 10 | ;----------------------------------------------------------- 11 | 12 | ;----------------------------------------------------------- 13 | ; Useful Rom Routines 14 | ;----------------------------------------------------------- 15 | 16 | ROM_CLS: EQU $0D6B 17 | ROM_CHAN_OPEN: EQU $1601 18 | ROM_PR_STRING: EQU $203C 19 | ROM_DRAW_LINE: EQU $24B7 20 | ROM_STACK_AEDCB:EQU $2AB6 21 | ROM_STK_TO_AEDCB:EQU $2BF1 22 | ROM_STACK_A: EQU $2D28 23 | ROM_STACK_BC: EQU $2D2B 24 | ROM_STK_TO_BC: EQU $2DA2 25 | ROM_STK_TO_A: EQU $2DD5 26 | ROM_FP_TESTZERO:EQU $34E9 27 | 28 | ;----------------------------------------------------------- 29 | ; Floating Point commands 30 | ;----------------------------------------------------------- 31 | 32 | FP_JUMP_TRUE: EQU 0 33 | FP_EXCHANGE: EQU 1 34 | FP_DELETE: EQU 2 35 | FP_SUBTRACT: EQU 3 36 | FP_MULTIPLY: EQU 4 37 | FP_DIVISION: EQU 5 38 | FP_TO_POWER: EQU 6 39 | FP_ADDITION: EQU 15 40 | FP_NEGATE: EQU 27 41 | FP_ABS: EQU 42 42 | FP_DUPLICATE: EQU 49 43 | FP_JUMP: EQU 51 44 | FP_LESS_ZERO: EQU 54 45 | FP_GREATER_ZERO:EQU 55 46 | FP_END: EQU 56 47 | FP_STK_ZERO: EQU 160 48 | FP_STK_ONE: EQU 161 49 | FP_STK_HALF: EQU 162 50 | FP_STK_PI_2: EQU 163 51 | FP_STK_TEN: EQU 164 52 | FP_ST_MEM_0: EQU 192 53 | FP_ST_MEM_1: EQU 193 54 | FP_ST_MEM_2: EQU 194 55 | FP_ST_MEM_3: EQU 195 56 | FP_ST_MEM_4: EQU 196 57 | FP_ST_MEM_5: EQU 197 58 | FP_GET_MEM_0: EQU 224 59 | FP_GET_MEM_1: EQU 225 60 | FP_GET_MEM_2: EQU 226 61 | FP_GET_MEM_3: EQU 227 62 | FP_GET_MEM_4: EQU 228 63 | FP_GET_MEM_5: EQU 229 64 | 65 | ;----------------------------------------------------------- 66 | ; Useful System Variables 67 | ;----------------------------------------------------------- 68 | 69 | SVAR_COORDS_X: EQU $5C7D 70 | SVAR_COORDS_Y: EQU $5C7E 71 | 72 | ;----------------------------------------------------------- 73 | 74 | ORG $8000 75 | 76 | ;----------------------------------------------------------- 77 | 78 | Start: 79 | ; As we are using the ROM, it can get funny if we 80 | ; mess up the EXX registers (especially HL), save them all 81 | exx 82 | push hl 83 | push bc 84 | push de 85 | exx 86 | 87 | ; Clear the screen 88 | call ROM_CLS 89 | 90 | ; Lets open stream for writing etc, for testing 91 | ld a, 2 92 | call ROM_CHAN_OPEN 93 | 94 | ; First lets set some point 95 | ld a, 100 96 | ld (Point1_StartX), a 97 | ld a, 10 98 | ld (Point1_StartY), a 99 | 100 | ld a, 220 101 | ld (Point1_EndX), a 102 | ld a, 150 103 | ld (Point1_EndY), a 104 | 105 | ; Setup the next point 106 | ld a, 120 107 | ld (Point2_StartX), a 108 | ld a, 100 109 | ld (Point2_StartY), a 110 | 111 | ld a, 200 112 | ld (Point2_EndX), a 113 | ld a, 40 114 | ld (Point2_EndY), a 115 | 116 | ; For debug lets draw the lines 117 | call DrawDebug 118 | 119 | ; Test if the lines collide 120 | call LINES_CollideTest 121 | jr c, _NoCollision 122 | 123 | ld de, CollisionString 124 | ld bc, CollisionStringEnd - CollisionString 125 | call ROM_PR_STRING 126 | jr _DonePrint 127 | _NoCollision: 128 | ld de, NoCollisionString 129 | ld bc, CollisionStringEnd - NoCollisionString 130 | call ROM_PR_STRING 131 | 132 | _DonePrint 133 | ; Restore the register pairs so we can return to basic 134 | exx 135 | pop de 136 | pop bc 137 | pop hl 138 | exx 139 | 140 | ret 141 | 142 | ;----------------------------------------------------------- 143 | ; Returns with Carry Set if there is no collision, else carry clear 144 | LINES_CollideTest: 145 | ; We need to calculate a few things 146 | ; denom = (y4-y3) * (x2-x1) - (x4-x3) * (y2-y1) 147 | 148 | ld a, (Point2_EndX) 149 | call ROM_STACK_A 150 | ld a, (Point2_StartX) 151 | call ROM_STACK_A 152 | ld a, (Point1_EndY) 153 | call ROM_STACK_A 154 | ld a, (Point1_StartY) 155 | call ROM_STACK_A 156 | 157 | ld a, (Point2_EndY) 158 | call ROM_STACK_A 159 | ld a, (Point2_StartY) 160 | call ROM_STACK_A 161 | ld a, (Point1_EndX) 162 | call ROM_STACK_A 163 | ld a, (Point1_StartX) 164 | call ROM_STACK_A 165 | 166 | rst $28 ; x4, x3, y2, y1, y4, y3, x2, x1 167 | db FP_SUBTRACT ; x4, x3, y2, y1, y4, y3, (x2-x1) 168 | db FP_ST_MEM_0 ; x4, x3, y2, y1, y4, y3, (x2-x1) 169 | db FP_DELETE ; x4, x3, y2, y1, y4, y3 170 | db FP_SUBTRACT ; x4, x3, y2, y1, (y4-y3) 171 | db FP_GET_MEM_0 ; x4, x3, y2, y1, (y4-y3), (x2-x1) 172 | db FP_MULTIPLY ; x4, x3, y2, y1, (y4-y3)(x2-x1) 173 | db FP_ST_MEM_1 ; x4, x3, y2, y1, (y4-y3)(x2-x1) 174 | db FP_DELETE ; x4, x3, y2, y1 175 | db FP_SUBTRACT ; x4, x3, (y2-y1) 176 | db FP_ST_MEM_0 ; x4, x3, (y2-y1) 177 | db FP_DELETE ; x4, x3 178 | db FP_SUBTRACT ; (x4-x3) 179 | db FP_GET_MEM_0 ; (x4-x3), (y2-y1) 180 | db FP_MULTIPLY ; (x4-x3)(y2-y1) 181 | db FP_GET_MEM_1 ; (x4-x3)(y2-y1), (y4-y3)(x2-x1) 182 | db FP_EXCHANGE ; (y4-y3)(x2-x1), (x4-x3)(y2-y1) 183 | db FP_SUBTRACT ; (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 184 | db FP_ST_MEM_2 ; (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 185 | db FP_END 186 | 187 | call ROM_FP_TESTZERO 188 | ret c 189 | 190 | ;numera = (x4-x3) * (y1-y3) - (y4-y3) * (x1-x3) 191 | ld a, (Point2_EndY) 192 | call ROM_STACK_A 193 | ld a, (Point2_StartY) 194 | call ROM_STACK_A 195 | ld a, (Point1_StartX) 196 | call ROM_STACK_A 197 | ld a, (Point2_StartX) 198 | call ROM_STACK_A 199 | 200 | ld a, (Point2_EndX) 201 | call ROM_STACK_A 202 | ld a, (Point2_StartX) 203 | call ROM_STACK_A 204 | ld a, (Point1_StartY) 205 | call ROM_STACK_A 206 | ld a, (Point2_StartY) 207 | call ROM_STACK_A 208 | 209 | rst $28 ; y4, y3, x1, x3, x4, x3, y1, y3 210 | db FP_SUBTRACT ; y4, y3, x1, x3, x4, x3, (y1-y3) 211 | db FP_ST_MEM_0 ; y4, y3, x1, x3, x4, x3, (y1-y3) 212 | db FP_DELETE ; y4, y3, x1, x3, x4, x3 213 | db FP_SUBTRACT ; y4, y3, x1, x3, (x4-x3) 214 | db FP_GET_MEM_0 ; y4, y3, x1, x3, (x4-x3), (y1-y3) 215 | db FP_MULTIPLY ; y4, y3, x1, x3, (x4-x3)(y1-y3) 216 | db FP_ST_MEM_1 ; y4, y3, x1, x3, (x4-x3)(y1-y3) 217 | db FP_DELETE ; y4, y3, x1, x3 218 | db FP_SUBTRACT ; y4, y3, (x1-x3) 219 | db FP_ST_MEM_0 ; y4, y3, (x1-x3) 220 | db FP_DELETE ; y4, y3 221 | db FP_SUBTRACT ; (y4-y3) 222 | db FP_GET_MEM_0 ; (y4-y3), (x1-x3) 223 | db FP_MULTIPLY ; (y4-y3)(x1-x3) 224 | db FP_GET_MEM_1 ; (y4-y3)(x1-x3), (x4-x3)(y1-y3) 225 | db FP_EXCHANGE ; (x4-x3)(y1-y3), (y4-y3)(x1-x3) 226 | db FP_SUBTRACT ; (x4-x3)(y1-y3)-(y4-y3)(x1-x3) 227 | db FP_GET_MEM_2 ; (x4-x3)(y1-y3)-(y4-y3)(x1-x3), (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 228 | db FP_DIVISION ; (x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 229 | db FP_DUPLICATE ; (x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1), (x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 230 | db FP_LESS_ZERO ; (x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1), (0/1) 231 | db FP_JUMP_TRUE, 5 ; Jump to end if less than 0 232 | db FP_STK_ONE ; (x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1), 1 233 | db FP_EXCHANGE ; 1, (x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 234 | db FP_SUBTRACT ; 1-((x4-x3)(y1-y3)-(y4-y3)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1)) 235 | db FP_LESS_ZERO ; (<0) 236 | db FP_END 237 | 238 | call ROM_FP_TESTZERO 239 | ccf 240 | ret c 241 | 242 | ;numerb = (x2-x1) * (y1-y3) - (y2-y1) * (x1-x3) 243 | ld a, (Point1_EndY) 244 | call ROM_STACK_A 245 | ld a, (Point1_StartY) 246 | call ROM_STACK_A 247 | ld a, (Point1_StartX) 248 | call ROM_STACK_A 249 | ld a, (Point2_StartX) 250 | call ROM_STACK_A 251 | 252 | ld a, (Point1_EndX) 253 | call ROM_STACK_A 254 | ld a, (Point1_StartX) 255 | call ROM_STACK_A 256 | ld a, (Point1_StartY) 257 | call ROM_STACK_A 258 | ld a, (Point2_StartY) 259 | call ROM_STACK_A 260 | 261 | rst $28 ; y2, y1, x1, x3, x2, x1, y1, y3 262 | db FP_SUBTRACT ; y2, y1, x1, x3, x2, x1, (y1-y3) 263 | db FP_ST_MEM_0 ; y2, y1, x1, x3, x2, x1, (y1-y3) 264 | db FP_DELETE ; y2, y1, x1, x3, x2, x1 265 | db FP_SUBTRACT ; y2, y1, x1, x3, (x2-x1) 266 | db FP_GET_MEM_0 ; y2, y1, x1, x3, (x2-x1), (y1-y3) 267 | db FP_MULTIPLY ; y2, y1, x1, x3, (x2-x1)(y1-y3) 268 | db FP_ST_MEM_1 ; y2, y1, x1, x3, (x2-x1)(y1-y3) 269 | db FP_DELETE ; y2, y1, x1, x3 270 | db FP_SUBTRACT ; y2, y1, (x1-x3) 271 | db FP_ST_MEM_0 ; y2, y1, (x1-x3) 272 | db FP_DELETE ; y2, y1 273 | db FP_SUBTRACT ; (y2-y1) 274 | db FP_GET_MEM_0 ; (y2-y1), (x1-x3) 275 | db FP_MULTIPLY ; (y2-y1)(x1-x3) 276 | db FP_GET_MEM_1 ; (y2-y1)(x1-x3), (x2-x1)(y1-y3) 277 | db FP_EXCHANGE ; (x2-x1)(y1-y3), (y2-y1)(x1-x3) 278 | db FP_SUBTRACT ; (x2-x1)(y1-y3)-(y2-y1)(x1-x3) 279 | db FP_GET_MEM_2 ; (x2-x1)(y1-y3)-(y2-y1)(x1-x3), (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 280 | db FP_DIVISION ; (x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 281 | db FP_DUPLICATE ; (x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1), (x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 282 | db FP_LESS_ZERO ; (x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1), (0/1) 283 | db FP_JUMP_TRUE, 5 ; Jump to end if less than 0 284 | db FP_STK_ONE ; (x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1), 1 285 | db FP_EXCHANGE ; 1, (x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1) 286 | db FP_SUBTRACT ; 1-((x2-x1)(y1-y3)-(y2-y1)(x1-x3) / (y4-y3)(x2-x1)-(x4-x3)(y2-y1)) 287 | db FP_LESS_ZERO ; (<0) 288 | db FP_END 289 | 290 | call ROM_FP_TESTZERO 291 | ccf 292 | 293 | ret 294 | 295 | ;----------------------------------------------------------- 296 | 297 | DrawDebug: 298 | ; Draw Line 1 299 | ld a, (Point1_EndX) 300 | call ROM_STACK_A 301 | ld a, (Point1_StartX) 302 | ld (SVAR_COORDS_X), a ; Remember the starting X point 303 | call ROM_STACK_A 304 | 305 | ; Get the length in floating point 306 | rst $28 307 | db FP_SUBTRACT 308 | db FP_END 309 | 310 | ld a, (Point1_EndY) 311 | call ROM_STACK_A 312 | ld a, (Point1_StartY) 313 | ld (SVAR_COORDS_Y), a ; Remember the starting Y point 314 | call ROM_STACK_A 315 | 316 | ; Get the length in floating point 317 | rst $28 318 | db FP_SUBTRACT 319 | db FP_END 320 | 321 | call ROM_DRAW_LINE 322 | 323 | ; Draw Line 2 324 | ld a, (Point2_EndX) 325 | call ROM_STACK_A 326 | ld a, (Point2_StartX) 327 | ld (SVAR_COORDS_X), a ; Remember the starting X point 328 | call ROM_STACK_A 329 | 330 | ; Get the length in floating point 331 | rst $28 332 | db FP_SUBTRACT 333 | db FP_END 334 | 335 | ld a, (Point2_EndY) 336 | call ROM_STACK_A 337 | ld a, (Point2_StartY) 338 | ld (SVAR_COORDS_Y), a ; Remember the starting Y point 339 | call ROM_STACK_A 340 | 341 | ; Get the length in floating point 342 | rst $28 343 | db FP_SUBTRACT 344 | db FP_END 345 | 346 | call ROM_DRAW_LINE 347 | 348 | ret 349 | 350 | ;----------------------------------------------------------- 351 | ; Variables 352 | ;----------------------------------------------------------- 353 | 354 | NoCollisionString: 355 | db "No " 356 | CollisionString: 357 | db "Collision" 358 | CollisionStringEnd: 359 | 360 | Point1_StartX: db 0 361 | Point1_StartY: db 0 362 | Point1_EndX: db 0 363 | Point1_EndY: db 0 364 | 365 | Point2_StartX: db 0 366 | Point2_StartY: db 0 367 | Point2_EndX: db 0 368 | Point2_EndY: db 0 369 | 370 | ;----------------------------------------------------------- 371 | 372 | END Start 373 | 374 | -------------------------------------------------------------------------------- /Maths/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Maths/empty.txt -------------------------------------------------------------------------------- /Misc/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Misc/empty.txt -------------------------------------------------------------------------------- /Screen/Double-buffering/polomint/generate_screen_table.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Written by John Young (polomint77) 25/04/2014 using Polo'Ed (Z80 Asm Editor) 3 | ; 4 | ; 5 | ; 6 | ; Create lookup table for transferring flat screen to speccy screen.. 7 | ; 8 | ; Used for transferring a back screen which has each pixel line 32 bytes after the previous one. 9 | ; 10 | ; NOTE: this will convert (x,y) 0, 0..191 to the correct address for the spectrum screen display 11 | ; and place that address into the lookup table... 12 | ; 13 | ; 14 | 15 | generate_screen_table: 16 | ; 17 | ld bc,0 ; first clear the x,y coords (b=y, c=x) 18 | ld hl, screen_table ; where to put the table 19 | ld d, 192 ; 192 lines on the display k, :p 20 | ld e, 0 21 | next_screen_line: 22 | push de ; save the loop counter for now 23 | push bc ; save the coords 24 | 25 | ld a, b ; fetch vertical coords 26 | ld e, a 27 | ; find line within cell 28 | and 7 ; line 0-7 within character square 29 | add a, 64 ; 64*256 = 16384 = start of screen display 30 | ld d, a ; line * 256 31 | ; find which third of the screen we're in 32 | ld a, e ; restore the vertical 33 | and 192 ; segment 0, 1 or 2 multiplied by 64 34 | rrca ; divide this by 8 35 | rrca 36 | rrca ; segment 0-2 multiplied by 8 37 | add a, d ; add to d give segment address 38 | ld d, a 39 | ; find character cell within segment 40 | ld a, e ; 8 character squares per segment 41 | rlca ; divide x by 8 and multiply by 32 42 | rlca ; net calculation: multiply by 4 43 | and 224 ; mask off bits we don't want 44 | ld e, a ; vertical coordinate calculation done 45 | 46 | ; add the horizontal element 47 | ; not really needed but ehhh what the hell, the table is only done once, :) 48 | ;ld a, c ; x coordinate 49 | ;rrca ; only need to divide by 8 50 | ;rrca 51 | ;rrca 52 | ;and 31 ; squares 0..31 across screen 53 | ;add a, e ; add to total so far 54 | ;ld e, a ; de = address of screen 55 | 56 | ld (hl), e 57 | inc hl 58 | ld (hl), d ; plonk the screen location for the current coord into the lookup table 59 | inc hl 60 | 61 | pop bc ; restore the coords 62 | inc b ; next line please 63 | 64 | pop de ; I take that loop counter back now, :) 65 | dec d ; decrement the loop... 66 | ld a, d 67 | and a 68 | jr nz, next_screen_line 69 | 70 | ld bc, screen_table ; remove this if you don't need the lookup_table location to be returned...... 71 | ret ; exit before summat goes wrong, ;) 72 | 73 | ; the addresses of the start of each display line are here.. [0..191] 74 | ; DONT FORGET: Anything code/data located after here for 384 bytes will be destroyed when the generate routine is called !!! 75 | ; although 384 bytes is a handy chunk for other stuff, which can be overwritten if's only being used once, eg, music etc.. 76 | screen_table: 77 | ds 384 78 | -------------------------------------------------------------------------------- /Screen/Double-buffering/polomint/transfer_buffer_screen_to_main_screen.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Written by John Young (polomint77) 25/04/2014 using Polo'Ed (Z80 Asm Editor) 3 | ; 4 | ; 5 | ; Transfer back buffer screen to main spectrum screen 6 | ; 7 | ; 8 | ; The back buffer screen is at 32768 (you can re-org it at 49152 or whatever if you like) 9 | ; add 6912 bytes to get to transfer_back_to_front routine... (39680d or $9B00) 10 | ; 11 | org 32768 12 | back_buffer_screen: 13 | incbin "jazz.bmp" ; remove if you don't have a scr to hand or don't need this... 14 | 15 | 16 | org 32768+6912 17 | 18 | ;------------------------------------------------------------------------- 19 | ; approx 100224 t-states to transfer the back buffer to the speccy screen 20 | ;------------------------------------------------------------------------- 21 | init: 22 | call generate_screen_table 23 | transfer_back_to_front: 24 | di 25 | ld hl, back_buffer_screen 26 | ld bc, 192*32 27 | ld (storesp), sp 28 | ld sp, screen_table 29 | line_loop: 30 | pop de ; get the speccy screen line address using sp 31 | REPT 32 32 | ldi 33 | ENDM 34 | jp pe, line_loop 35 | ld sp, (storesp) 36 | ei 37 | ret 38 | 39 | 40 | storesp: defw 0 ; place to save sp 41 | include "generate_screen_table.asm" 42 | 43 | -------------------------------------------------------------------------------- /Sound/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Sound/empty.txt -------------------------------------------------------------------------------- /Sprites/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Sprites/empty.txt -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook.zip -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 1 - 1 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0D6B 14 | 15 | ; Return to BASIC 16 | ret 17 | 18 | ;----------------------------------------------------------- 19 | 20 | END Start 21 | 22 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 1/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 1 - 2 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0D6B 14 | 15 | ; Display a G 16 | ld a, 'G' 17 | rst 16 18 | 19 | ; Return to BASIC 20 | ret 21 | 22 | ;----------------------------------------------------------- 23 | 24 | END Start 25 | 26 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 2/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 1 - 3 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0DAF 14 | 15 | ; Display Hello World 16 | ld a, 'H' 17 | rst 16 18 | ld a, 'e' 19 | rst 16 20 | ld a, 'l' 21 | rst 16 22 | ld a, 'l' 23 | rst 16 24 | ld a, 'o' 25 | rst 16 26 | ld a, ' ' 27 | rst 16 28 | ld a, 'W' 29 | rst 16 30 | ld a, 'o' 31 | rst 16 32 | ld a, 'r' 33 | rst 16 34 | ld a, 'l' 35 | rst 16 36 | ld a, 'd' 37 | rst 16 38 | 39 | ; Return to BASIC 40 | ret 41 | 42 | ;----------------------------------------------------------- 43 | 44 | END Start 45 | 46 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 3/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 1 - 4 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0DAF 14 | 15 | ; Display Hello World 16 | ld hl, String 17 | ld b, 11 18 | 19 | Loop: ; Get the character from HL and move on 20 | ld a, (hl) 21 | inc hl 22 | 23 | ; Write it to the screen 24 | rst 16 25 | 26 | ; Loop through them all 27 | djnz Loop 28 | 29 | ; Return to BASIC 30 | ret 31 | 32 | ;----------------------------------------------------------- 33 | 34 | ; You can also use dm instead of db to define a message eg. dm "Hello World" 35 | String: db 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' 36 | 37 | ;----------------------------------------------------------- 38 | 39 | END Start 40 | 41 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 4/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 1 - 5 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0DAF 14 | 15 | ; Display Hello World 16 | ld hl, String 17 | ld b, 14 18 | 19 | Loop: ; Get the character from HL and move on 20 | ld a, (hl) 21 | inc hl 22 | 23 | ; Write it to the screen 24 | rst 16 25 | 26 | ; Loop through them all 27 | djnz Loop 28 | 29 | ; Return to BASIC 30 | ret 31 | 32 | ;----------------------------------------------------------- 33 | 34 | ; You can also use dm instead of db to define a message eg. dm "Hello World" 35 | String: db 22, 5, 5, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' 36 | 37 | ;----------------------------------------------------------- 38 | 39 | END Start 40 | 41 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/main.tap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Part 1 - 5/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 1/Z80 Assembler - Part 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 1/Z80 Assembler - Part 1.pdf -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 2/Z80 Assembler - Part 2 .pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 2/Z80 Assembler - Part 2 .pdf -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 3 - 1 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0DAF 14 | 15 | ld a, %10011111 16 | 17 | ; Display A 18 | ld h, 0 19 | ld l, 0 20 | call DisplayBinary 21 | 22 | ; Perform the NOT 23 | cpl 24 | 25 | ; Display the new value below the first 26 | ld h, 1 27 | ld l, 0 28 | call DisplayBinary 29 | 30 | ; Return to BASIC 31 | ret 32 | 33 | ;----------------------------------------------------------- 34 | ; Inputs: 35 | ; A = Value to display 36 | ; L = X Position 37 | ; H = Y Position 38 | 39 | DisplayBinary: 40 | push bc 41 | push hl 42 | push af 43 | 44 | ; Remember A 45 | ld c, a 46 | 47 | ; Write out the set position information 48 | ld a, 22 49 | rst &10 50 | ld a, h 51 | rst &10 52 | ld a, l 53 | rst &10 54 | 55 | ; Need to do 8 bits 56 | ld b, 8 57 | Loop: 58 | ; Shift the bit off the top 59 | rl c 60 | 61 | ; Set A to 0 or 1 as needed 62 | ld a, '0' 63 | jr nc, BitZero 64 | ld a, '1' 65 | BitZero: 66 | ; Print it 67 | rst &10 68 | 69 | ; Do all 8 bits 70 | djnz Loop 71 | pop af 72 | pop hl 73 | pop bc 74 | ret 75 | 76 | ;----------------------------------------------------------- 77 | 78 | END Start 79 | 80 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 1/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/Z80.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Z80", "Z80.vcxproj", "{298A88FB-BFB4-44BD-8F6E-2601D70B3C03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Debug|Win32.Build.0 = Debug|Win32 16 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.ActiveCfg = Release|Win32 17 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/Z80.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {298A88FB-BFB4-44BD-8F6E-2601D70B3C03} 15 | MakeFileProj 16 | 10.0.17134.0 17 | 18 | 19 | 20 | Makefile 21 | true 22 | v141 23 | 24 | 25 | Makefile 26 | false 27 | v141 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | cmd /c build.bat 41 | main.tap 42 | cmd /c clean.bat 43 | cmd /c rebuild.bat 44 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 45 | 46 | 47 | cmd /c build.bat 48 | main.tap 49 | cmd /c clean.bat 50 | cmd /c rebuild.bat 51 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/Z80.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Batch Files 7 | 8 | 9 | Batch Files 10 | 11 | 12 | Batch Files 13 | 14 | 15 | 16 | 17 | {d455c6d0-d6ec-4255-badb-14336203a215} 18 | 19 | 20 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/build.bat: -------------------------------------------------------------------------------- 1 | ..\..\tools\pasmo.exe -1 --tapbas main.asm main.tap main.sym -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/clean.bat: -------------------------------------------------------------------------------- 1 | del main.tap -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/main.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------- 2 | ; 3 | ; Z80 Assmebler - Part 3 - 1 4 | ; 5 | ;----------------------------------------------------------- 6 | 7 | ORG $8000 8 | 9 | ;----------------------------------------------------------- 10 | 11 | Start: 12 | ; Clear the screen 13 | call 0x0DAF 14 | 15 | ld a, %10110011 16 | ld b, %10001010 17 | 18 | ; Display A 19 | ld h, 0 20 | ld l, 0 21 | call DisplayBinary 22 | 23 | ; Display B 24 | ld h, 1 25 | ld l, 0 26 | 27 | ; We need to put the value of B into A to display it (So remember A) 28 | push af 29 | ld a, b 30 | call DisplayBinary 31 | pop af 32 | 33 | ; Perform the AND 34 | and b 35 | 36 | ; Display the new value below the first 37 | ld h, 2 38 | ld l, 0 39 | call DisplayBinary 40 | 41 | ; Return to BASIC 42 | ret 43 | 44 | ;----------------------------------------------------------- 45 | ; Inputs: 46 | ; A = Value to display 47 | ; L = X Position 48 | ; H = Y Position 49 | 50 | DisplayBinary: 51 | push bc 52 | push hl 53 | push af 54 | 55 | ; Remember A 56 | ld c, a 57 | 58 | ; Write out the set position information 59 | ld a, 22 60 | rst &10 61 | ld a, h 62 | rst &10 63 | ld a, l 64 | rst &10 65 | 66 | ; Need to do 8 bits 67 | ld b, 8 68 | Loop: 69 | ; Shift the bit off the top 70 | rl c 71 | 72 | ; Set A to 0 or 1 as needed 73 | ld a, '0' 74 | jr nc, BitZero 75 | ld a, '1' 76 | BitZero: 77 | ; Print it 78 | rst &10 79 | 80 | ; Do all 8 bits 81 | djnz Loop 82 | pop af 83 | pop hl 84 | pop bc 85 | ret 86 | 87 | ;----------------------------------------------------------- 88 | 89 | END Start 90 | 91 | -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Part 3 - 2/rebuild.bat: -------------------------------------------------------------------------------- 1 | call clean.bat 2 | call build.bat -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Z80 Assembler - Part 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 3/Z80 Assembler - Part 3.pdf -------------------------------------------------------------------------------- /Tutorials/Z80 Assembler Facebook/Part 3/Z80 Assembler - Part 3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/Z80 Assembler Facebook/Part 3/Z80 Assembler - Part 3.zip -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/100px-ZXSpectrum48k.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/100px-ZXSpectrum48k.jpg -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-Folder_Hexagonal_Icon.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-Folder_Hexagonal_Icon.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum80.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum80.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum81.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum81.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum82.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum82.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum83.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum83.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum84.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum84.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum85.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum85.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum86.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum86.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum87.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum87.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum88.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum88.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum89.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum89.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8a.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8a.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8b.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8b.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8c.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8c.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8d.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8d.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8e.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/16px-ZXSpectrum8e.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/ZXSpectrum8f.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/ZXSpectrum8f.svg.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/ZX_Spectrum_character_set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/ZX_Spectrum_character_set.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/ZX_Spectrum_character_set_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/ZX_Spectrum_character_set_demo.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/load(2).php: -------------------------------------------------------------------------------- 1 | div#editpage-specialchars{display:block;border:1px solid #c0c0c0;padding:.5em 1em}div#editpage-specialchars a{background-color:#f9f9f9;border:1px solid #ddd;padding:1px 4px}textarea#wpTextbox1 + div#editpage-specialchars,div.wikiEditor-ui-clear + div#editpage-specialchars{border-top:none} -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/load(3).php: -------------------------------------------------------------------------------- 1 | cite,dfn{font-style:inherit}q{quotes:'"' '"' "'" "'"}blockquote{overflow:hidden;margin:1em 0;padding:0 40px}strong.selflink{font-weight:700}small{font-size:85%}.mw-body-content sub,.mw-body-content sup,span.reference{font-size:80%}.ns-talk .mw-body-content dd{margin-top:0.4em;margin-bottom:0.4em}#interwiki-completelist{font-weight:bold}.client-js .mw-special-Watchlist #watchlist-message,.client-js .NavFrame.collapsed .NavContent,.client-js .collapsible:not(.mw-made-collapsible).collapsed > tbody > tr:not(:first-child){display:none}#toolbar{margin-bottom:6px}#editpage-specialchars{display:none}body.action-info .mw-body-content :target,.citation:target{background-color:#DEF;background-color:rgba(0,127,255,0.133)}.citation{word-wrap:break-word}@media screen,handheld{.citation .printonly{display:none}}ol.references,div.reflist,div.refbegin{font-size:90%;margin-bottom:0.5em}div.refbegin-100{font-size:100%}div.reflist ol.references{font-size:100%;margin-bottom:0;list-style-type:inherit}sup.reference{font-weight:normal;font-style:normal}span.brokenref{display:none}.refbegin-hanging-indents > ul{list-style-type:none;margin-left:0}.refbegin-hanging-indents > ul > li,.refbegin-hanging-indents > dl > dd{margin-left:0;padding-left:3.2em;text-indent:-3.2em;list-style:none}div.columns{margin-top:0.3em}div.columns dl,div.columns ol,div.columns ul{margin-top:0}.nocolbreak,div.columns li,div.columns dd dd{-webkit-column-break-inside:avoid;page-break-inside:avoid;break-inside:avoid-column}.flowlist ul{overflow-x:hidden;margin-left:0;padding-left:1.6em}.flowlist ol{overflow-x:hidden;margin-left:0;padding-left:3.2em}.flowlist dl{overflow-x:hidden}.hlist dl,.hlist ol,.hlist ul{margin:0;padding:0}.hlist dd,.hlist dt,.hlist li{margin:0;display:inline}.hlist.inline,.hlist.inline dl,.hlist.inline ol,.hlist.inline ul,.hlist dl dl,.hlist dl ol,.hlist dl ul,.hlist ol dl,.hlist ol ol,.hlist ol ul,.hlist ul dl,.hlist ul ol,.hlist ul ul{display:inline}.hlist .mw-empty-li{display:none}.hlist dt:after{content:":"}.hlist dd:after,.hlist li:after{content:" · ";font-weight:bold}.hlist dd:last-child:after,.hlist dt:last-child:after,.hlist li:last-child:after{content:none}.hlist dd dd:first-child:before,.hlist dd dt:first-child:before,.hlist dd li:first-child:before,.hlist dt dd:first-child:before,.hlist dt dt:first-child:before,.hlist dt li:first-child:before,.hlist li dd:first-child:before,.hlist li dt:first-child:before,.hlist li li:first-child:before{content:" (";font-weight:normal}.hlist dd dd:last-child:after,.hlist dd dt:last-child:after,.hlist dd li:last-child:after,.hlist dt dd:last-child:after,.hlist dt dt:last-child:after,.hlist dt li:last-child:after,.hlist li dd:last-child:after,.hlist li dt:last-child:after,.hlist li li:last-child:after{content:")";font-weight:normal}.hlist ol{counter-reset:listitem}.hlist ol > li{counter-increment:listitem}.hlist ol > li:before{content:" " counter(listitem) "\a0"}.hlist dd ol > li:first-child:before,.hlist dt ol > li:first-child:before,.hlist li ol > li:first-child:before{content:" (" counter(listitem) "\a0"}.plainlist ol,.plainlist ul{line-height:inherit;list-style:none none;margin:0}.plainlist ol li,.plainlist ul li{margin-bottom:0}.navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.navbox .navbox{margin-top:0}.navbox + .navbox{margin-top:-1px}.navbox-inner,.navbox-subgroup{width:100%}.navbox-group,.navbox-title,.navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}th.navbox-group{white-space:nowrap;text-align:right}.navbox,.navbox-subgroup{background:#fdfdfd}.navbox-list{line-height:1.5em;border-color:#fdfdfd}tr + tr > .navbox-abovebelow,tr + tr > .navbox-group,tr + tr > .navbox-image,tr + tr > .navbox-list{border-top:2px solid #fdfdfd}.navbox th,.navbox-title{background:#ccccff}.navbox-abovebelow,th.navbox-group,.navbox-subgroup .navbox-title{background:#ddddff}.navbox-subgroup .navbox-group,.navbox-subgroup .navbox-abovebelow{background:#e6e6ff}.navbox-even{background:#f7f7f7}.navbox-odd{background:transparent}.navbox .hlist td dl,.navbox .hlist td ol,.navbox .hlist td ul,.navbox td.hlist dl,.navbox td.hlist ol,.navbox td.hlist ul{padding:0.125em 0}.navbar{display:inline;font-size:88%;font-weight:normal}.navbar ul{display:inline;white-space:nowrap}.mw-body-content .navbar ul{line-height:inherit}.navbar li{word-spacing:-0.125em}.navbar.mini li abbr[title]{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.infobox .navbar{font-size:100%}.navbox .navbar{display:block;font-size:100%}.navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}.collapseButton{float:right;font-weight:normal;margin-left:0.5em;text-align:right;width:auto}.mw-parser-output .mw-collapsible-toggle{font-weight:normal;text-align:right;padding-right:0.2em;padding-left:0.2em}.mw-collapsible-leftside-toggle .mw-collapsible-toggle{float:left;text-align:left}.infobox{border:1px solid #a2a9b1;border-spacing:3px;background-color:#f8f9fa;color:black;margin:0.5em 0 0.5em 1em;padding:0.2em;float:right;clear:right;font-size:88%;line-height:1.5em}.infobox caption{font-size:125%;font-weight:bold;padding:0.2em;text-align:center}.infobox td,.infobox th{vertical-align:top;text-align:left}.infobox.bordered{border-collapse:collapse}.infobox.bordered td,.infobox.bordered th{border:1px solid #a2a9b1}.infobox.bordered .borderless td,.infobox.bordered .borderless th{border:0}.infobox.sisterproject{width:20em;font-size:90%}.infobox.standard-talk{border:1px solid #c0c090;background-color:#f8eaba}.infobox.standard-talk.bordered td,.infobox.standard-talk.bordered th{border:1px solid #c0c090}.infobox.bordered .mergedtoprow td,.infobox.bordered .mergedtoprow th{border:0;border-top:1px solid #a2a9b1;border-right:1px solid #a2a9b1}.infobox.bordered .mergedrow td,.infobox.bordered .mergedrow th{border:0;border-right:1px solid #a2a9b1}.infobox.geography{border-collapse:collapse;line-height:1.2em;font-size:90%}.infobox.geography td,.infobox.geography th{border-top:1px solid #a2a9b1;padding:0.4em 0.6em 0.4em 0.6em}.infobox.geography .mergedtoprow td,.infobox.geography .mergedtoprow th{border-top:1px solid #a2a9b1;padding:0.4em 0.6em 0.2em 0.6em}.infobox.geography .mergedrow td,.infobox.geography .mergedrow th{border:0;padding:0 0.6em 0.2em 0.6em}.infobox.geography .mergedbottomrow td,.infobox.geography .mergedbottomrow th{border-top:0;border-bottom:1px solid #a2a9b1;padding:0 0.6em 0.4em 0.6em}.infobox.geography .maptable td,.infobox.geography .maptable th{border:0;padding:0}.wikitable.plainrowheaders th[scope=row]{font-weight:normal;text-align:left}.wikitable td ul,.wikitable td ol,.wikitable td dl{text-align:left}.toc.hlist ul,#toc.hlist ul,.wikitable.hlist td ul,.wikitable.hlist td ol,.wikitable.hlist td dl{text-align:inherit}div.listenlist{background:url(//upload.wikimedia.org/wikipedia/commons/4/47/Sound-icon.svg) no-repeat scroll 0 0 transparent;background-size:30px;padding-left:40px}table.mw-hiero-table td{vertical-align:middle}div.medialist{min-height:50px;margin:1em;background-position:top left;background-repeat:no-repeat}div.medialist ul{list-style-type:none;list-style-image:none;margin:0}div.medialist ul li{padding-bottom:0.5em}div.medialist ul li li{font-size:91%;padding-bottom:0}div#content a[href$=".pdf"].external,div#content a[href*=".pdf?"].external,div#content a[href*=".pdf#"].external,div#content a[href$=".PDF"].external,div#content a[href*=".PDF?"].external,div#content a[href*=".PDF#"].external,div#mw_content a[href$=".pdf"].external,div#mw_content a[href*=".pdf?"].external,div#mw_content a[href*=".pdf#"].external,div#mw_content a[href$=".PDF"].external,div#mw_content a[href*=".PDF?"].external,div#mw_content a[href*=".PDF#"].external{background:url(//upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif) no-repeat right;padding-right:18px}div.columns-2 div.column{float:left;width:50%;min-width:300px}div.columns-3 div.column{float:left;width:33.3%;min-width:200px}div.columns-4 div.column{float:left;width:25%;min-width:150px}div.columns-5 div.column{float:left;width:20%;min-width:120px}.messagebox{border:1px solid #a2a9b1;background-color:#f8f9fa;width:80%;margin:0 auto 1em auto;padding:.2em}.messagebox.merge{border:1px solid #c0b8cc;background-color:#f0e5ff;text-align:center}.messagebox.cleanup{border:1px solid #9f9fff;background-color:#efefff;text-align:center}.messagebox.standard-talk{border:1px solid #c0c090;background-color:#f8eaba;margin:4px auto}.mbox-inside .standard-talk,.messagebox.nested-talk{border:1px solid #c0c090;background-color:#f8eaba;width:100%;margin:2px 0;padding:2px}.messagebox.small{width:238px;font-size:85%;float:right;clear:both;margin:0 0 1em 1em;line-height:1.25em}.messagebox.small-talk{width:238px;font-size:85%;float:right;clear:both;margin:0 0 1em 1em;line-height:1.25em;background:#F8EABA}th.mbox-text,td.mbox-text{border:none;padding:0.25em 0.9em;width:100%}td.mbox-image{border:none;padding:2px 0 2px 0.9em;text-align:center}td.mbox-imageright{border:none;padding:2px 0.9em 2px 0;text-align:center}td.mbox-empty-cell{border:none;padding:0;width:1px}table.ambox{margin:0 10%;border:1px solid #a2a9b1;border-left:10px solid #36c;background:#fbfbfb;box-sizing:border-box}table.ambox + table.ambox{margin-top:-1px}.ambox th.mbox-text,.ambox td.mbox-text{padding:0.25em 0.5em}.ambox td.mbox-image{padding:2px 0 2px 0.5em}.ambox td.mbox-imageright{padding:2px 0.5em 2px 0}table.ambox-notice{border-left:10px solid #36c}table.ambox-speedy{border-left:10px solid #b32424;background:#fee7e6}table.ambox-delete{border-left:10px solid #b32424}table.ambox-content{border-left:10px solid #f28500}table.ambox-style{border-left:10px solid #fc3}table.ambox-move{border-left:10px solid #9932cc}table.ambox-protection{border-left:10px solid #a2a9b1}table.imbox{margin:4px 10%;border-collapse:collapse;border:3px solid #36c;background:#fbfbfb;box-sizing:border-box}.imbox .mbox-text .imbox{margin:0 -0.5em;display:block}.mbox-inside .imbox{margin:4px}table.imbox-notice{border:3px solid #36c}table.imbox-speedy{border:3px solid #b32424;background:#fee7e6}table.imbox-delete{border:3px solid #b32424}table.imbox-content{border:3px solid #f28500}table.imbox-style{border:3px solid #fc3}table.imbox-move{border:3px solid #9932cc}table.imbox-protection{border:3px solid #a2a9b1}table.imbox-license{border:3px solid #88a;background:#f7f8ff}table.imbox-featured{border:3px solid #cba135}table.cmbox{margin:3px 10%;border-collapse:collapse;border:1px solid #a2a9b1;background:#DFE8FF;box-sizing:border-box}table.cmbox-notice{background:#D8E8FF}table.cmbox-speedy{margin-top:4px;margin-bottom:4px;border:4px solid #b32424;background:#FFDBDB}table.cmbox-delete{background:#FFDBDB}table.cmbox-content{background:#FFE7CE}table.cmbox-style{background:#FFF9DB}table.cmbox-move{background:#E4D8FF}table.cmbox-protection{background:#EFEFE1}table.ombox{margin:4px 10%;border-collapse:collapse;border:1px solid #a2a9b1;background:#f8f9fa;box-sizing:border-box}table.ombox-notice{border:1px solid #a2a9b1}table.ombox-speedy{border:2px solid #b32424;background:#fee7e6}table.ombox-delete{border:2px solid #b32424}table.ombox-content{border:1px solid #f28500}table.ombox-style{border:1px solid #fc3}table.ombox-move{border:1px solid #9932cc}table.ombox-protection{border:2px solid #a2a9b1}table.tmbox{margin:4px 10%;border-collapse:collapse;border:1px solid #c0c090;background:#f8eaba;min-width:80%;box-sizing:border-box}.tmbox.mbox-small{min-width:0}.mediawiki .mbox-inside .tmbox{margin:2px 0;width:100%}.mbox-inside .tmbox.mbox-small{line-height:1.5em;font-size:100%}table.tmbox-speedy{border:2px solid #b32424;background:#fee7e6}table.tmbox-delete{border:2px solid #b32424}table.tmbox-content{border:2px solid #f28500}table.tmbox-style{border:2px solid #fc3}table.tmbox-move{border:2px solid #9932cc}table.tmbox-protection,table.tmbox-notice{border:1px solid #c0c090}table.dmbox{clear:both;margin:0.9em 1em;border-top:1px solid #ccc;border-bottom:1px solid #ccc;background:transparent}table.fmbox{clear:both;margin:0.2em 0;width:100%;border:1px solid #a2a9b1;background:#f8f9fa;box-sizing:border-box}table.fmbox-system{background:#f8f9fa}table.fmbox-warning{border:1px solid #bb7070;background:#ffdbdb}table.fmbox-editnotice{background:transparent}div.mw-warning-with-logexcerpt,div.mw-lag-warn-high,div.mw-cascadeprotectedwarning,div#mw-protect-cascadeon,div.titleblacklist-warning,div.locked-warning{clear:both;margin:0.2em 0;border:1px solid #bb7070;background:#ffdbdb;padding:0.25em 0.9em;box-sizing:border-box}html body.mediawiki .mbox-small{clear:right;float:right;margin:4px 0 4px 1em;box-sizing:border-box;width:238px;font-size:88%;line-height:1.25em}html body.mediawiki .mbox-small-left{margin:4px 1em 4px 0;box-sizing:border-box;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.compact-ambox table .mbox-image,.compact-ambox table .mbox-imageright,.compact-ambox table .mbox-empty-cell{display:none}.compact-ambox table.ambox{border:none;border-collapse:collapse;background:transparent;margin:0 0 0 1.6em !important;padding:0 !important;width:auto;display:block}body.mediawiki .compact-ambox table.mbox-small-left{font-size:100%;width:auto;margin:0}.compact-ambox table .mbox-text{padding:0 !important;margin:0 !important}.compact-ambox table .mbox-text-span{display:list-item;line-height:1.5em;list-style-type:square;list-style-image:url(//en.wikipedia.org/w/skins/MonoBook/resources/images/bullet.gif)}.skin-vector .compact-ambox table .mbox-text-span{list-style-type:disc;list-style-image:url(//en.wikipedia.org/w/skins/Vector/images/bullet-icon.svg);list-style-image:url(//en.wikipedia.org/w/skins/Vector/images/bullet-icon.png)\9}.compact-ambox .hide-when-compact{display:none}div.noarticletext{border:none;background:transparent;padding:0}.visualhide{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.check-icon a.new{display:none;speak:none}.nounderlines a,.IPA a:link,.IPA a:visited{text-decoration:none !important}div.NavFrame{margin:0;padding:4px;border:1px solid #a2a9b1;text-align:center;border-collapse:collapse;font-size:95%}div.NavFrame + div.NavFrame{border-top-style:none;border-top-style:hidden}div.NavPic{background-color:#fff;margin:0;padding:2px;float:left}div.NavFrame div.NavHead{line-height:1.6em;font-weight:bold;background-color:#ccf;position:relative}div.NavFrame p,div.NavFrame div.NavContent,div.NavFrame div.NavContent p{font-size:100%}div.NavEnd{margin:0;padding:0;line-height:1px;clear:both}a.NavToggle{position:absolute;top:0;right:3px;font-weight:normal;font-size:90%}.hatnote{font-style:italic}.hatnote i{font-style:normal}div.hatnote{padding-left:1.6em;margin-bottom:0.5em}div.hatnote + div.hatnote{margin-top:-0.5em}.listify td{display:list-item}.listify tr{display:block}.listify table{display:block}.geo-default,.geo-dms,.geo-dec{display:inline}.geo-nondefault,.geo-multi-punct{display:none}.longitude,.latitude{white-space:nowrap}.hlist .tocnumber,.hlist .toctext{display:inline}.nonumtoc .tocnumber{display:none}.nonumtoc #toc ul,.nonumtoc .toc ul{line-height:1.5em;list-style:none none;margin:.3em 0 0;padding:0}.hlist.nonumtoc #toc ul ul,.hlist.nonumtoc .toc ul ul{margin:0}.toclimit-2 .toclevel-1 ul,.toclimit-3 .toclevel-2 ul,.toclimit-4 .toclevel-3 ul,.toclimit-5 .toclevel-4 ul,.toclimit-6 .toclevel-5 ul,.toclimit-7 .toclevel-6 ul{display:none}blockquote.templatequote div.templatequotecite{line-height:1.5em;text-align:left;padding-left:1.6em;margin-top:0}div.user-block{padding:5px;margin-bottom:0.5em;border:1px solid #A9A9A9;background-color:#FFEFD5}.nowrap,.nowraplinks a,.nowraplinks .selflink{white-space:nowrap}.nowrap pre{white-space:pre}.wrap,.wraplinks a{white-space:normal}.template-documentation{clear:both;margin:1em 0 0 0;border:1px solid #a2a9b1;background-color:#ecfcf4;padding:1em}#wpUploadDescription{height:13em}.thumbinner{min-width:100px}#mw-subcategories,#mw-pages,#mw-category-media,#filehistory,#wikiPreview,#wikiDiff{clear:both}.wpb .wpb-header{display:none}.wpbs-inner .wpb .wpb-header{display:block}.wpbs-inner .wpb .wpb-header{display:table-row}.wpbs-inner .wpb-outside{display:none}.mw-tag-markers{font-style:italic;font-size:90%}.sysop-show,.templateeditor-show,.extendedmover-show,.patroller-show,.autoconfirmed-show,.user-show{display:none}.ve-ui-mwNoticesPopupTool-item .editnotice-redlink,.ve-ui-mwNoticesPopupTool-item .mbox-image,.ve-ui-mwNoticesPopupTool-item .mbox-imageright{display:none !important}ul.permissions-errors > li{list-style:none none}ul.permissions-errors{margin:0}.transborder{border:solid transparent}.times-serif,span.texhtml{font-family:"Nimbus Roman No9 L","Times New Roman",Times,serif;font-size:118%;line-height:1}span.texhtml{white-space:nowrap}span.texhtml span.texhtml{font-size:100%}span.mwe-math-mathml-inline{font-size:118%}.digits,.texhtml{-moz-font-feature-settings:"lnum","tnum","kern" 0;-webkit-font-feature-settings:"lnum","tnum","kern" 0;font-feature-settings:"lnum","tnum","kern" 0;font-variant-numeric:lining-nums tabular-nums;font-kerning:none}.mwe-math-fallback-image-display,.mwe-math-mathml-display{margin-left:1.6em !important;margin-top:0.6em;margin-bottom:0.6em}.mwe-math-mathml-display math{display:inline}table#mw-prefixindex-list-table,table#mw-prefixindex-nav-table{width:98%}.portal-column-left{float:left;width:50%}.portal-column-right{float:right;width:49%}.portal-column-left-wide{float:left;width:60%}.portal-column-right-narrow{float:right;width:39%}.portal-column-left-extra-wide{float:left;width:70%}.portal-column-right-extra-narrow{float:right;width:29%}@media only screen and (max-width:800px){.portal-column-left,.portal-column-right,.portal-column-left-wide,.portal-column-right-narrow,.portal-column-left-extra-wide,.portal-column-right-extra-narrow{float:inherit;width:inherit}}#bodyContent .letterhead{background-image:url(//upload.wikimedia.org/wikipedia/commons/e/e0/Tan-page-corner.png);background-repeat:no-repeat;padding:2em;background-color:#faf9f2}.treeview ul{padding:0;margin:0}.treeview li{padding:0;margin:0;list-style-type:none;list-style-image:none}.treeview li li{background:url(//upload.wikimedia.org/wikipedia/commons/f/f2/Treeview-grey-line.png) no-repeat 0 -2981px;padding-left:20px;text-indent:0.3em}.treeview li li.lastline{background-position:0 -5971px }.treeview li.emptyline > ul{margin-left:-1px}.treeview li.emptyline > ul > .mw-empty-elt:first-child + .emptyline,.treeview li.emptyline > ul > li:first-child{background-position:0 9px }td .sortkey,th .sortkey{display:none;speak:none}.inputbox-hidecheckboxes form .inputbox-element,.inputbox-hidecheckboxes .mw-ui-checkbox{display:none !important}.k-player .k-attribution{visibility:hidden}.PopUpMediaTransform a .play-btn-large{margin:0;top:auto;right:auto;bottom:0;left:0}.flaggedrevs_draft_synced,.flaggedrevs_stable_synced{display:none}.bordered-images img{border:solid #ddd 1px}@media screen{#content .gallerybox div.thumb{background-color:#f8f9fa}.gallerybox .thumb img{background:#fff url(//upload.wikimedia.org/wikipedia/commons/5/5d/Checker-16x16.png) repeat}.ns-0 .gallerybox .thumb img,.ns-2 .gallerybox .thumb img,.ns-100 .gallerybox .thumb img,.nochecker .gallerybox .thumb img{background:#fff}}.page-Main_Page #deleteconfirm,.page-Main_Page #t-cite,.page-Main_Page #footer-info-lastmod,.action-view.page-Main_Page #siteSub,.action-view.page-Main_Page #contentSub,.action-view.page-Main_Page .firstHeading{display:none !important}#coordinates{position:absolute;top:0;right:0;float:right;margin:0;padding:0;line-height:1.5em;text-align:right;text-indent:0;font-size:85%;text-transform:none;white-space:nowrap}.ve-ce-surface-enabled #coordinates{margin-right:2em;margin-top:-1em}.mw-indicator #coordinates{position:absolute;top:3em;right:0;line-height:1.6;text-align:right;font-size:92%;white-space:nowrap}div.flaggedrevs_short{position:absolute;top:-3em;right:100px;z-index:1}@media screen{#siteSub{display:block;font-size:92%}}.mw-body .mw-indicators{padding-top:0.4em}@media print{.ns--1 .ambox,.ns-0 .ambox,.ns--1 .navbox,.ns-0 .navbox,.ns--1 .vertical-navbox,.ns-0 .vertical-navbox,.ns--1 .infobox.sisterproject,.ns-0 .infobox.sisterproject,.ns--1 .hatnote,.ns-0 .hatnote,.ns--1 .dablink,.ns-0 .dablink,.ns--1 .metadata,.ns-0 .metadata,.sistersitebox,.editlink,.navbar,a.NavToggle,span.collapseButton,span.mw-collapsible-toggle,th .sortkey,td .sortkey,#mw-revision-nav{display:none !important}.nourlexpansion a.external.text:after,.nourlexpansion a.external.autonumber:after{display:none !important}table.collapsible tr,div.NavPic,div.NavContent{display:block !important}table.collapsible tr{display:table-row !important}.mw-parser-output .mw-collapsed .mw-collapsible-content{display:block !important}.mw-parser-output table.mw-collapsed > * > tr{display:table-row !important}.mw-parser-output ol.mw-collapsed > li,.mw-parser-output ul.mw-collapsed > li{display:list-item !important}#firstHeading{margin:0}#content a.external.text:after,#content a.external.autonumber:after{word-wrap:break-word}.infobox{border:solid 1px #aaa;background-color:#fff;border-spacing:0;border-collapse:collapse;width:180pt !important}.infobox > * > tr > td,.infobox > * > tr > th{padding:2px 5px;border-bottom:1px solid #EAECF0}.infobox a,.infobox > * > tr:last-child > th,.infobox > * > tr:last-child > td{border:0}.refbegin a,.references a,.reference a{color:black !important}sup,sub{line-height:1}sup.reference{font-family:sans-serif}.reference a{border-bottom:0}ol.references,div.reflist,div.refbegin,cite *{font-size:inherit !important}.refbegin li,.references li{color:#666;line-height:14pt}.printfooter{clear:both}} -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/poweredby_mediawiki_88x31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/poweredby_mediawiki_88x31.png -------------------------------------------------------------------------------- /Tutorials/ZX Spectrum character set - Wikipedia_files/wikimedia-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Tutorials/ZX Spectrum character set - Wikipedia_files/wikimedia-button.png -------------------------------------------------------------------------------- /Utilities/empty.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxasm/z80/241afd19395b9eafad9370cd5fda351b5fd19f7c/Utilities/empty.txt -------------------------------------------------------------------------------- /Utilities/z80heap.asm: -------------------------------------------------------------------------------- 1 | ; ========================================================== 2 | ; Simple ZX Spectrum heap memory manager 3 | ; 4 | ; (c) 2016 Peter Hanratty 5 | ; Email: peter.neil.hanratty@gmail.com 6 | ; 7 | ; Free for non-commercial use with the following conditions: 8 | ; - Credit where credit is due, do not remove this notice or 9 | ; any other information identifying the author 10 | ; - Any additions or modifications should be clearly marked 11 | ; with the contributor's name 12 | ; - Please include an honourable mention in any projects 13 | ; which use this lib 14 | ; ========================================================== 15 | ; 16 | ; Functions: 17 | ; ---------------------------------------------------------- 18 | ; 19 | ; HEAP_INIT - Call this before doing anything else 20 | ; HL = Address for allocation table 21 | ; (NOTE: table is unbounded, beware of overruns) 22 | ; DE = Start of heap, all memory allocated from this block 23 | ; BC = Heap size 24 | ; 25 | ; HEAP_ALLOC - Allocates a block of memory from the heap 26 | ; BC = Block size 27 | ; Returns: Pointer address in HL (or 0000H if unsuccessfu) 28 | ; 29 | ; HEAP_FREE - Free previously allocated block 30 | ; (if found in table, otherwise do nothing) 31 | ; HL = Pointer to block 32 | ; 33 | ; HEAP_MEMSET - Fill a block of memory with a byte value 34 | ; HL = Pointer to memory 35 | ; BC = Number of bytes to fill 36 | ; A = Byte value 37 | ; 38 | ; ========================================================== 39 | 40 | HEAP_ALLOCTABLE: 41 | 42 | ; Format: Unbounded dense list 43 | ; [2] Heap start address 44 | ; [2(n)] eassssss ssssssss (e=end, a=allocated, s=size) 45 | 46 | ; Pointer to allocation table (above label serves as address) 47 | DW FFFFH 48 | 49 | ; ========================================================== 50 | 51 | HEAP_INIT: 52 | ; Initialise memory manager 53 | ; HL = allocation table 54 | ; DE = heap start 55 | ; BC = heap size 56 | 57 | LD (HEAP_ALLOCTABLE), HL 58 | LD (HL), E 59 | INC HL 60 | LD (HL), D 61 | INC HL 62 | LD (HL), C 63 | INC HL 64 | LD A, B ; Set a single free block with BC 65 | AND 3FH ; as its size and flag as last 66 | OR 80H 67 | LD (HL), A 68 | RET 69 | 70 | ; ---------------------------------------------------------- 71 | 72 | HEAP_ALLOC: 73 | ; Allocate pointer and return in HL 74 | ; BC = Size 75 | 76 | LD IY, (HEAP_ALLOCTABLE) 77 | LD D, (IY+1) ; Read heap start address 78 | LD E, (IY+0) ; Into DE 79 | 80 | HEAP_ALLOC_FIRSTFREE: 81 | INC IY ; Next block 82 | INC IY 83 | LD L, (IY+0) ; Read block info 84 | LD A, (IY+1) ; into HL 85 | AND 3FH 86 | LD H, A ; Block size only in HL 87 | BIT 6, (IY+1) ; Allocated? 88 | JR NZ, HEAP_ALLOC_NEXTBLOCK 89 | PUSH HL 90 | SBC HL, BC ; Big enough? 91 | POP HL 92 | JR NC, HEAP_ALLOC_FOUNDFREE 93 | BIT 7, (IY+1) ; Was it the last block (remaining free space)? 94 | JR NZ, HEAP_ALLOC_NOROOM 95 | 96 | HEAP_ALLOC_NEXTBLOCK: 97 | ADD HL, DE ; Calculate address of next block 98 | EX DE, HL 99 | JR HEAP_ALLOC_FIRSTFREE 100 | 101 | HEAP_ALLOC_FOUNDFREE: 102 | LD A, (IY+1) 103 | SBC HL, BC ; Leftover bytes in HL 104 | SET 6, B ; Flag block as allocated 105 | LD (IY+0), C ; Write new block size 106 | LD (IY+1), B 107 | BIT 7, A ; Was it the last block (remaining free space)? 108 | JR Z, HEAP_ALLOC_INSERT 109 | SET 7, H ; Append new end block with remaining free space 110 | LD (IY+2), L 111 | LD (IY+3), H 112 | EX DE, HL 113 | RET 114 | 115 | HEAP_ALLOC_INSERT: 116 | LD A, L ; Still need to deal with any leftover free space 117 | OR H 118 | JR NZ, HEAP_ALLOC_NEWBLOCK 119 | EX DE, HL 120 | RET ; Return if none 121 | 122 | HEAP_ALLOC_NEWBLOCK: 123 | PUSH DE 124 | LD BC, 0002H ; Else we have to shuffle everything else along... 125 | PUSH HL 126 | PUSH IY 127 | POP HL 128 | INC HL 129 | INC HL 130 | INC HL ; Make sure we're looking at the high address bytes 131 | 132 | HEAP_ALLOC_FINDLAST: 133 | BIT 7, (HL) 134 | JR NZ, HEAP_ALLOC_SHUFFLE 135 | INC HL 136 | INC HL 137 | INC BC 138 | INC BC 139 | JR HEAP_ALLOC_FINDLAST 140 | 141 | HEAP_ALLOC_SHUFFLE: 142 | LD D, H 143 | LD E, L 144 | INC DE 145 | INC DE 146 | LDDR 147 | EX DE, HL 148 | POP DE 149 | LD (HL), D ; Insert new free block 150 | DEC HL 151 | LD (HL), E 152 | POP HL 153 | RET 154 | 155 | HEAP_ALLOC_NOROOM: 156 | LD HL, 0000H 157 | RET 158 | 159 | ; ---------------------------------------------------------- 160 | 161 | HEAP_FREE: 162 | ; Free memory pointed to by HL (if in table) 163 | 164 | LD IY, (HEAP_ALLOCTABLE) 165 | LD D, (IY+1) ; Read heap start address 166 | LD E, (IY+0) 167 | EX DE, HL 168 | 169 | HEAP_FREE_FINDPTR: 170 | INC IY 171 | INC IY 172 | LD C, (IY+0) 173 | LD A, (IY+1) 174 | AND 3FH 175 | LD B, A ; Store block size only in BC 176 | LD A, D 177 | CP H ; Compare pointer with current offset in heap area 178 | RET C ; Exit if past pointer address 179 | JR NZ, HEAP_FREE_NEXTPTR 180 | LD A, E 181 | CP L 182 | JR Z, HEAP_FREE_FOUNDPTR 183 | 184 | HEAP_FREE_NEXTPTR: 185 | BIT 7, (IY+1) ; Last block? 186 | RET NZ 187 | ADD HL, BC 188 | JR HEAP_FREE_FINDPTR 189 | 190 | HEAP_FREE_FOUNDPTR: 191 | RES 6, (IY+1) ; clear allocated flag 192 | PUSH IY 193 | POP HL 194 | LD DE, (HEAP_ALLOCTABLE) 195 | XOR A 196 | LD C, A 197 | LD (HEAP_FREE_MERGEUP_REWRITE-1), A ; Zero offset 198 | SBC HL, DE ; Look for previous free blocks to merge with 199 | JR Z, HEAP_FREE_MERGEUP_START 200 | SRL H ; Dvide by 2 201 | RR L 202 | LD B, L ; NOTE: This will cause problems with any more than 255 blocks 203 | 204 | HEAP_FREE_MERGEDOWN: 205 | DEC IY 206 | DEC IY 207 | BIT 6, (IY+1) 208 | JR NZ, HEAP_FREE_MERGEDOWN_FOUNDALLOC 209 | DJNZ HEAP_FREE_MERGEDOWN 210 | JR HEAP_FREE_MERGEUP_START 211 | 212 | HEAP_FREE_MERGEDOWN_FOUNDALLOC: 213 | INC IY 214 | INC IY 215 | 216 | HEAP_FREE_MERGEUP_START: 217 | PUSH IY ; Merge all subsequent free blocks including last 218 | LD H, (IY+1) 219 | LD A, (IY+0) 220 | AND 3FH 221 | LD L, A 222 | XOR A 223 | LD B, A 224 | LD c, A 225 | 226 | HEAP_FREE_MERGEUP: 227 | INC IY 228 | INC IY 229 | JR HEAP_FREE_MERGEUP_REWRITE ; Code rewrite - stop merging when allocated 230 | ; block found (still need to shuffle the list) 231 | HEAP_FREE_MERGEUP_REWRITE: 232 | LD A, (IY+1) ; 3 233 | BIT 6, A ; 2 234 | JR Z, HEAP_FREE_MERGEUP_ADDSIZE ; 2 235 | LD A, 23 ; New offset ; 2 236 | LD (HEAP_FREE_MERGEUP_REWRITE-1), A ; 3 237 | JR HEAP_FREE_MERGEUP_SKIPADD ; 2 238 | 239 | HEAP_FREE_MERGEUP_ADDSIZE: 240 | AND 3FH ; 2 241 | LD D, A ; 2 242 | LD E, (IY+0) ; 3 243 | ADD HL, DE ; 1 244 | INC C ; 1 245 | 246 | HEAP_FREE_MERGEUP_SKIPADD: ; = 23 247 | INC B 248 | BIT 7, (IY+1) ; Last block? 249 | JR Z, HEAP_FREE_MERGEUP 250 | POP DE 251 | EX DE, HL 252 | LD (HL), E ; Write new block size 253 | INC HL 254 | LD (HL), D 255 | LD A, B 256 | SUB C ; Mereged all the way to the end? 257 | JR NZ, HEAP_FREE_SHUFFLE 258 | SET 7, (HL) ; Set end flag 259 | RET ; and exit 260 | 261 | HEAP_FREE_SHUFFLE: 262 | DEC C ; If no merges (single block freed), 263 | RET M ; no shuffle necessary 264 | INC C 265 | INC HL 266 | LD D, H 267 | LD E, L 268 | LD A, B 269 | LD B, 0 270 | ADD HL, BC 271 | ADD HL, BC 272 | LD C, A 273 | SLA C ; Multiply by 2 274 | RL B 275 | LDIR 276 | RET 277 | 278 | ; ---------------------------------------------------------- 279 | 280 | HEAP_MEMSET: 281 | ; Fill memory with specified value 282 | ; HL = pointer 283 | ; BC = size 284 | ; A = value 285 | 286 | DEC BC 287 | RET M ; Return if 0 bytes 288 | INC BC 289 | LD (HL), A 290 | DEC BC 291 | RET Z ; Return if only 1 byte 292 | LD D, H 293 | LD E, L 294 | INC DE 295 | LDIR ; Fill the rest 296 | RET 297 | 298 | ; ========================================================== 299 | --------------------------------------------------------------------------------