------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm LEVEL 1 PASS 3 1 10000 ???? ; MACRO.H 2 10000 ???? 3 10000 ???? ; Based on the 2600 macro.h file. 4 10000 ???? ; Macros irrelevant to the 7800 have been removed, and the sleep macro 5 10000 ???? ; has been adapted to give accurate results on the 7800. 6 10000 ???? 7 10000 ???? ; Version 1.0 2019/12/11 (based on the 2600 Version 1.05, 13/NOVEMBER/2003) 8 10000 ???? 9 10000 ???? ; Available macros... 10 10000 ???? ; SLEEP n - sleep for n cycles 11 10000 ???? ; SET_POINTER - load a 16-bit absolute to a 16-bit variable 12 10000 ???? 13 10000 ???? ;------------------------------------------------------------------------------- 14 10000 ???? ; SLEEP duration 15 10000 ???? ; Original author: Thomas Jentzsch 16 10000 ???? ; Inserts code which takes the specified number of cycles to execute. This is 17 10000 ???? ; useful for code where precise timing is required. 18 10000 ???? ; ILLEGAL-OPCODE VERSION DOES NOT AFFECT FLAGS OR REGISTERS. 19 10000 ???? ; LEGAL OPCODE VERSION MAY AFFECT FLAGS 20 10000 ???? ; Uses illegal opcode (DASM 2.20.01 onwards). 21 10000 ???? 22 10000 ???? MAC sleep 23 10000 ???? .CYCLES SET {1} 24 10000 ???? 25 10000 ???? IF .CYCLES < 2 26 10000 ???? ECHO "MACRO ERROR: 'SLEEP': Duration must be > 1" 27 10000 ???? ERR 28 10000 ???? ENDIF 29 10000 ???? 30 10000 ???? IF .CYCLES & 1 31 10000 ???? IFNCONST NO_ILLEGAL_OPCODES 32 10000 ???? nop $80 33 10000 ???? ELSE 34 10000 ???? bit $80 35 10000 ???? ENDIF 36 10000 ???? .CYCLES SET .CYCLES - 3 37 10000 ???? ENDIF 38 10000 ???? 39 10000 ???? REPEAT .CYCLES / 2 40 10000 ???? nop 41 10000 ???? REPEND 42 10000 ???? ENDM ;usage: SLEEP n (n>1) 43 10000 ???? 44 10000 ???? ;------------------------------------------------------- 45 10000 ???? ; SET_POINTER 46 10000 ???? ; Original author: Manuel Rotschkar 47 10000 ???? ; 48 10000 ???? ; Sets a 2 byte RAM pointer to an absolute address. 49 10000 ???? ; 50 10000 ???? ; Usage: SET_POINTER pointer, address 51 10000 ???? ; Example: SET_POINTER SpritePTR, SpriteData 52 10000 ???? ; 53 10000 ???? ; Note: Alters the accumulator, NZ flags 54 10000 ???? ; IN 1: 2 byte RAM location reserved for pointer 55 10000 ???? ; IN 2: absolute address 56 10000 ???? 57 10000 ???? MAC set_pointer 58 10000 ???? .POINTER SET {1} 59 10000 ???? .ADDRESS SET {2} 60 10000 ???? 61 10000 ???? LDA #<.ADDRESS ; Get Lowbyte of Address 62 10000 ???? STA .POINTER ; Store in pointer 63 10000 ???? LDA #>.ADDRESS ; Get Hibyte of Address 64 10000 ???? STA .POINTER+1 ; Store in pointer+1 65 10000 ???? 66 10000 ???? ENDM 67 10000 ???? 68 10000 ???? ; EOF 69 10000 ???? ; Provided under the CC0 license. See the included LICENSE.txt for details. 70 10000 ???? 71 10000 ???? ; 7800MACRO.H 72 10000 ???? 73 10000 ???? ;------------------------------------------------------- 74 10000 ???? ; BOXCOLLISIONCHECK 75 10000 ???? ; author: Mike Saarna 76 10000 ???? ; 77 10000 ???? ; A general bounding box collision check. compares 2 rectangles of differing size 78 10000 ???? ; and shape for overlap. Carry is set for collision detected, clear for none. 79 10000 ???? ; 80 10000 ???? ; Usage: BOXCOLLISIONCHECK x1var,y1var,w1var,h1var,x2var,y2var,w2var,h2var 81 10000 ???? ; 82 10000 ???? 83 10000 ???? MAC boxcollisioncheck 84 10000 ???? .boxx1 SET {1} 85 10000 ???? .boxy1 SET {2} 86 10000 ???? .boxw1 SET {3} 87 10000 ???? .boxh1 SET {4} 88 10000 ???? .boxx2 SET {5} 89 10000 ???? .boxy2 SET {6} 90 10000 ???? .boxw2 SET {7} 91 10000 ???? .boxh2 SET {8} 92 10000 ???? 93 10000 ???? .DoXCollisionCheck 94 10000 ???? lda .boxx1 ;3 95 10000 ???? cmp .boxx2 ;2 96 10000 ???? bcs .X1isbiggerthanX2 ;2/3 97 10000 ???? .X2isbiggerthanX1 98 10000 ???? adc #.boxw1 ;2 99 10000 ???? cmp .boxx2 ;3 100 10000 ???? bcs .DoYCollisionCheck ;3/2 101 10000 ???? bcc .noboxcollision ;3 102 10000 ???? .X1isbiggerthanX2 103 10000 ???? clc ;2 104 10000 ???? sbc #.boxw2 ;2 105 10000 ???? cmp .boxx2 ;3 106 10000 ???? bcs .noboxcollision ;3/2 107 10000 ???? .DoYCollisionCheck 108 10000 ???? lda .boxy1 ;3 109 10000 ???? cmp .boxy2 ;3 110 10000 ???? bcs .Y1isbiggerthanY2 ;3/2 111 10000 ???? .Y2isbiggerthanY1 112 10000 ???? adc #.boxh1 ;2 113 10000 ???? cmp .boxy2 ;3 114 10000 ???? jmp .checkdone ;6 115 10000 ???? .Y1isbiggerthanY2 116 10000 ???? clc ;2 117 10000 ???? sbc #.boxh2 ;2 118 10000 ???? cmp .boxy2 ;3 119 10000 ???? bcs .noboxcollision ;3/2 120 10000 ???? .boxcollision 121 10000 ???? sec ;2 122 10000 ???? .byte $24 ; hardcoded "BIT [clc opcode]", used to skip over the following clc 123 10000 ???? .noboxcollision 124 10000 ???? clc ;2 125 10000 ???? .checkdone 126 10000 ???? 127 10000 ???? ENDM 128 10000 ???? 129 10000 ???? MAC median3 130 10000 ???? 131 10000 ???? ; A median filter (for smoothing paddle jitter) 132 10000 ???? ; this macro takes the current paddle value, compares it to historic 133 10000 ???? ; values, and replaces the current paddle value with the median. 134 10000 ???? ; 135 10000 ???? ; called as: MEDIAN3 STORAGE CURRENT 136 10000 ???? ; where STORAGE points to 3 consecutive bytes of memory. The first 2 137 10000 ???? ; must be dedicated to this MEDIAN filter. The last 1 is a temp. 138 10000 ???? ; where CURRENT is memory holding the new value you wish to compare to 139 10000 ???? ; the previous values, and update with the median value. 140 10000 ???? ; 141 10000 ???? ; returns: CURRENT (modified to contain median value) 142 10000 ???? ; 143 10000 ???? ; author: Mike Saarna (aka RevEng) 144 10000 ???? 145 10000 ???? .MedianBytes SET {1} 146 10000 ???? .NewValue SET {2} 147 10000 ???? 148 10000 ???? lda #0 149 10000 ???? ldy .NewValue 150 10000 ???? sty .MedianBytes+2 ; put the new value in the most "recent" slot 151 10000 ???? 152 10000 ???? ; build an index from relative size comparisons between our 3 values. 153 10000 ???? cpy .MedianBytes 154 10000 ???? rol 155 10000 ???? cpy .MedianBytes+1 156 10000 ???? rol 157 10000 ???? ldy .MedianBytes 158 10000 ???? cpy .MedianBytes+1 159 10000 ???? rol 160 10000 ???? tay 161 10000 ???? 162 10000 ???? ldx MedianOrderLUT,y ; convert the size-comparison index to an index to the median value 163 10000 ???? lda .MedianBytes,x 164 10000 ???? sta .NewValue ; we replace the new value memory with the median value 165 10000 ???? 166 10000 ???? ; then shift values from "newer" bytes to "older" bytes, leaving the 167 10000 ???? ; newest byte (.MedianBytes+2) empty for next time. 168 10000 ???? lda .MedianBytes+1 169 10000 ???? sta .MedianBytes 170 10000 ???? lda .MedianBytes+2 171 10000 ???? sta .MedianBytes+1 172 10000 ???? ifnconst MedianOrderLUT 173 10000 ???? jmp MedianOrderLUTend 174 10000 ???? MedianOrderLUT ; converts our "comparison index" to an index to the median value 175 10000 ???? .byte 0 ; 0 B2 < B0 < B1 176 10000 ???? .byte 1 ; 1 B2 < B1 < B0 177 10000 ???? .byte 2 ; 2 impossible 178 10000 ???? .byte 2 ; 3 B1 < B2 < B0 179 10000 ???? .byte 2 ; 4 B0 < B2 < B1 180 10000 ???? .byte 2 ; 5 impossible 181 10000 ???? .byte 1 ; 6 B0 < B1 < B2 182 10000 ???? .byte 0 ; 7 B1 < B0 < B2 183 10000 ???? MedianOrderLUTend 184 10000 ???? endif 185 10000 ???? ENDM 186 10000 ???? 187 10000 ???? MAC plotsprite 188 10000 ???? 189 10000 ???? ; A macro version of the plotsprite command. 190 10000 ???? ; This trades off rom space for speed. 191 10000 ???? ; It also doesn't check if the visible screen is displayed or not. 192 10000 ???? ; It has no training wheels. It is all rusty sharp edges. 193 10000 ???? 194 10000 ???? .GFXLabel SET {1} 195 10000 ???? .Palette SET {2} ; constant 196 10000 ???? .SpriteX SET {3} ; variable 197 10000 ???? .SpriteY SET {4} ; variable 198 10000 ???? .ByteOffset SET {5} ; variable 199 10000 ???? 200 10000 ???? lda .SpriteY 201 10000 ???? lsr 202 10000 ???? lsr 203 10000 ???? asr #%11111110 ; ensure carry is clear 204 10000 ???? if WZONEHEIGHT = 16 205 10000 ???? asr #%11111110 ; ensure carry is clear 206 10000 ???? endif 207 10000 ???? 208 10000 ???? tax 209 10000 ???? 210 10000 ???? lda DLPOINTL,x ; setup DL pointer for this zone 211 10000 ???? sta dlpnt 212 10000 ???? lda DLPOINTH,x ; setup DL pointer for this zone 213 10000 ???? sta dlpnt+1 214 10000 ???? 215 10000 ???? ldy dlend,x ; find the next new object position in this zone 216 10000 ???? 217 10000 ???? lda .ByteOffset 218 10000 ???? if {1}_width = 2 219 10000 ???? asl 220 10000 ???? endif 221 10000 ???? if {1}_width = 3 222 10000 ???? asl 223 10000 ???? adc .ByteOffset 224 10000 ???? endif 225 10000 ???? if {1}_width = 4 226 10000 ???? asl 227 10000 ???? asl 228 10000 ???? endif 229 10000 ???? if {1}_width = 5 230 10000 ???? asl 231 10000 ???? asl 232 10000 ???? adc .ByteOffset 233 10000 ???? endif 234 10000 ???? if {1}_width = 6 235 10000 ???? asl 236 10000 ???? adc .ByteOffset 237 10000 ???? asl 238 10000 ???? endif 239 10000 ???? if {1}_width = 7 240 10000 ???? asl 241 10000 ???? adc .ByteOffset 242 10000 ???? asl 243 10000 ???? adc .ByteOffset 244 10000 ???? endif 245 10000 ???? if {1}_width = 8 246 10000 ???? asl 247 10000 ???? asl 248 10000 ???? asl 249 10000 ???? endif 250 10000 ???? if {1}_width = 9 251 10000 ???? asl 252 10000 ???? asl 253 10000 ???? asl 254 10000 ???? adc .ByteOffset 255 10000 ???? endif 256 10000 ???? if {1}_width = 10 257 10000 ???? asl 258 10000 ???? asl 259 10000 ???? adc .ByteOffset 260 10000 ???? asl 261 10000 ???? endif 262 10000 ???? if {1}_width = 11 263 10000 ???? asl 264 10000 ???? asl 265 10000 ???? adc .ByteOffset 266 10000 ???? asl 267 10000 ???? adc .ByteOffset 268 10000 ???? endif 269 10000 ???? if {1}_width = 12 270 10000 ???? asl 271 10000 ???? adc .ByteOffset 272 10000 ???? asl 273 10000 ???? asl 274 10000 ???? endif 275 10000 ???? if {1}_width = 13 276 10000 ???? asl 277 10000 ???? adc .ByteOffset 278 10000 ???? asl 279 10000 ???? asl 280 10000 ???? adc .ByteOffset 281 10000 ???? endif 282 10000 ???? if {1}_width = 14 283 10000 ???? asl 284 10000 ???? adc .ByteOffset 285 10000 ???? asl 286 10000 ???? adc .ByteOffset 287 10000 ???? asl 288 10000 ???? endif 289 10000 ???? 290 10000 ???? adc #<.GFXLabel ; carry is clear via previous asl or asr 291 10000 ???? sta (dlpnt),y ; #1 - low byte object address 292 10000 ???? 293 10000 ???? iny 294 10000 ???? 295 10000 ???? lda #({1}_mode | %01000000) 296 10000 ???? sta (dlpnt),y ; #2 - graphics mode , indirect 297 10000 ???? 298 10000 ???? iny 299 10000 ???? 300 10000 ???? lda .SpriteY 301 10000 ???? and #(WZONEHEIGHT - 1) 302 10000 ???? cmp #1 ; clear carry if our sprite is just in this zone 303 10000 ???? ora #>.GFXLabel 304 10000 ???? sta (dlpnt),y ; #3 - hi byte object address 305 10000 ???? 306 10000 ???? iny 307 10000 ???? 308 10000 ???? lda #({1}_width_twoscompliment | (.Palette * 32)) 309 10000 ???? sta (dlpnt),y ; #4 - palette|width 310 10000 ???? 311 10000 ???? iny 312 10000 ???? 313 10000 ???? lda .SpriteX 314 10000 ???? sta (dlpnt),y ; #5 - x object position 315 10000 ???? 316 10000 ???? iny 317 10000 ???? sty dlend,x 318 10000 ???? 319 10000 ???? ifconst ALWAYSTERMINATE 320 10000 ???? iny 321 10000 ???? lda #0 322 10000 ???? sta (dlpnt),y 323 10000 ???? endif 324 10000 ???? 325 10000 ???? bcc .PLOTSPRITEend 326 10000 ???? 327 10000 ???? inx ; next zone 328 10000 ???? 329 10000 ???? lda DLPOINTL,x ; setup DL pointer for this zone 330 10000 ???? sta dlpnt 331 10000 ???? lda DLPOINTH,x ; setup DL pointer for this zone 332 10000 ???? sta dlpnt+1 333 10000 ???? 334 10000 ???? ldy dlend,x ; find the next new object position in this zone 335 10000 ???? 336 10000 ???? lda .ByteOffset 337 10000 ???? if {1}_width = 1 338 10000 ???? clc 339 10000 ???? endif 340 10000 ???? if {1}_width = 2 341 10000 ???? asl ; carry clear 342 10000 ???? endif 343 10000 ???? if {1}_width = 3 344 10000 ???? asl ; carry clear 345 10000 ???? adc .ByteOffset 346 10000 ???? endif 347 10000 ???? if {1}_width = 4 348 10000 ???? asl ; carry clear 349 10000 ???? asl 350 10000 ???? endif 351 10000 ???? if {1}_width = 5 352 10000 ???? asl ; carry clear 353 10000 ???? asl 354 10000 ???? adc .ByteOffset 355 10000 ???? endif 356 10000 ???? if {1}_width = 6 357 10000 ???? asl ; carry clear 358 10000 ???? adc .ByteOffset 359 10000 ???? asl 360 10000 ???? endif 361 10000 ???? if {1}_width = 7 362 10000 ???? asl ; carry clear 363 10000 ???? adc .ByteOffset 364 10000 ???? asl 365 10000 ???? endif 366 10000 ???? if {1}_width = 8 367 10000 ???? asl ; carry clear 368 10000 ???? asl 369 10000 ???? asl 370 10000 ???? endif 371 10000 ???? if {1}_width = 9 372 10000 ???? asl ; carry clear 373 10000 ???? asl 374 10000 ???? asl 375 10000 ???? adc .ByteOffset 376 10000 ???? endif 377 10000 ???? if {1}_width = 10 378 10000 ???? asl ; carry clear 379 10000 ???? asl 380 10000 ???? adc .ByteOffset 381 10000 ???? asl 382 10000 ???? endif 383 10000 ???? if {1}_width = 11 384 10000 ???? asl ; carry clear 385 10000 ???? asl 386 10000 ???? adc .ByteOffset 387 10000 ???? asl 388 10000 ???? adc .ByteOffset 389 10000 ???? endif 390 10000 ???? if {1}_width = 12 391 10000 ???? asl ; carry clear 392 10000 ???? adc .ByteOffset 393 10000 ???? asl 394 10000 ???? asl 395 10000 ???? endif 396 10000 ???? if {1}_width = 13 397 10000 ???? asl ; carry clear 398 10000 ???? adc .ByteOffset 399 10000 ???? asl 400 10000 ???? asl 401 10000 ???? adc .ByteOffset 402 10000 ???? endif 403 10000 ???? if {1}_width = 14 404 10000 ???? asl ; carry clear 405 10000 ???? adc .ByteOffset 406 10000 ???? asl 407 10000 ???? adc .ByteOffset 408 10000 ???? asl 409 10000 ???? endif 410 10000 ???? 411 10000 ???? adc #<.GFXLabel 412 10000 ???? sta (dlpnt),y ; #1 - low byte object address 413 10000 ???? 414 10000 ???? iny 415 10000 ???? 416 10000 ???? lda #({1}_mode | %01000000) 417 10000 ???? sta (dlpnt),y ; #2 - graphics mode , indirect 418 10000 ???? 419 10000 ???? iny 420 10000 ???? 421 10000 ???? lda .SpriteY 422 10000 ???? and #(WZONEHEIGHT - 1) 423 10000 ???? ora #>(.GFXLabel - (WZONEHEIGHT * 256)) ; start in the dma hole 424 10000 ???? sta (dlpnt),y ; #3 - hi byte object address 425 10000 ???? 426 10000 ???? iny 427 10000 ???? 428 10000 ???? lda #({1}_width_twoscompliment | (.Palette * 32)) 429 10000 ???? sta (dlpnt),y ; #4 - palette|width 430 10000 ???? 431 10000 ???? iny 432 10000 ???? 433 10000 ???? lda .SpriteX 434 10000 ???? sta (dlpnt),y ; #5 - x object position 435 10000 ???? 436 10000 ???? iny 437 10000 ???? sty dlend,x 438 10000 ???? 439 10000 ???? ifconst ALWAYSTERMINATE 440 10000 ???? iny 441 10000 ???? lda #0 442 10000 ???? sta (dlpnt),y 443 10000 ???? endif 444 10000 ???? 445 10000 ???? .PLOTSPRITEend 446 10000 ???? ENDM 447 10000 ???? 448 10000 ???? ; 449 10000 ???? ; speakjet.inc 450 10000 ???? ; 451 10000 ???? ; 452 10000 ???? ; AtariVox Speech Synth Driver 453 10000 ???? ; 454 10000 ???? ; By Alex Herbert, 2004 455 10000 ???? ; 456 10000 ???? 457 10000 ???? 458 10000 ???? 459 10000 ???? 460 10000 ???? ; Constants 461 10000 ???? 462 10000 ???? 463 10000 ???? 00 01 SERIAL_OUTMASK equ $01 464 10000 ???? 00 02 SERIAL_RDYMASK equ $02 465 10000 ???? 466 10000 ???? 467 10000 ???? 468 10000 ???? ; Macros 469 10000 ???? 470 10000 ???? mac spkout 471 10000 ???? 472 10000 ???? ; check buffer-full status 473 10000 ???? lda SWCHA 474 10000 ???? and #SERIAL_RDYMASK 475 10000 ???? beq .speech_done 476 10000 ???? 477 10000 ???? ; get next speech byte 478 10000 ???? ldy #$00 479 10000 ???? lda (speech_addr),y 480 10000 ???? 481 10000 ???? ; invert data and check for end of string 482 10000 ???? eor #$ff 483 10000 ???? ;sta BACKGRND ; debug - uncomment to flash the background color with vox data 484 10000 ???? beq .speech_done 485 10000 ???? sta {1} 486 10000 ???? 487 10000 ???? ; increment speech pointer 488 10000 ???? inc speech_addr 489 10000 ???? bne .incaddr_skip 490 10000 ???? inc speech_addr+1 491 10000 ???? .incaddr_skip 492 10000 ???? 493 10000 ???? ; output byte as serial data 494 10000 ???? 495 10000 ???? sec ; start bit 496 10000 ???? .byteout_loop 497 10000 ???? ; put carry flag into bit 0 of SWACNT, perserving other bits 498 10000 ???? lda SWACNT ; 4 499 10000 ???? and #$fe ; 2 6 500 10000 ???? adc #$00 ; 2 8 501 10000 ???? sta SWACNT ; 4 12 502 10000 ???? 503 10000 ???? ; 10 bits sent? (1 start bit, 8 data bits, 1 stop bit) 504 10000 ???? cpy #$09 ; 2 14 505 10000 ???? beq .speech_done ; 2 16 506 10000 ???? iny ; 2 18 507 10000 ???? 508 10000 ???? ; the 7800 is 1.5x faster than the 2600. Waste more cycles here 509 10000 ???? ; to match the original baud rate... 510 10000 ???? ;ldx #$07 ; 2600 511 10000 ???? ldx #$0D 512 10000 ???? 513 10000 ???? .delay_loop 514 10000 ???? dex ; 515 10000 ???? bne .delay_loop ; 36 54 516 10000 ???? 517 10000 ???? ; shift next data bit into carry 518 10000 ???? lsr {1} ; 5 59 519 10000 ???? 520 10000 ???? ; and loop (branch always taken) 521 10000 ???? bpl .byteout_loop ; 3 62 cycles for loop 522 10000 ???? 523 10000 ???? .speech_done 524 10000 ???? 525 10000 ???? endm 526 10000 ???? 527 10000 ???? 528 10000 ???? mac speak 529 10000 ???? 530 10000 ???? lda #<{1} 531 10000 ???? sta speech_addr 532 10000 ???? lda #>{1} 533 10000 ???? sta speech_addr+1 534 10000 ???? 535 10000 ???? endm 536 10000 ???? 537 10000 ???? 538 10000 ???? 539 10000 ???? ; Provided under the CC0 license. See the included LICENSE.txt for details. 540 10000 ???? 541 10000 ???? processor 6502 542 10000 ???? ------- FILE 7800basic.h LEVEL 2 PASS 3 0 10000 ???? include "7800basic.h" 1 10000 ???? ; Provided under the CC0 license. See the included LICENSE.txt for details. 2 10000 ???? 3 10000 ???? processor 6502 ------- FILE 7800.h LEVEL 3 PASS 3 0 10000 ???? include "7800.h" 1 10000 ???? ; Provided under the CC0 license. See the included LICENSE.txt for details. 2 10000 ???? 3 10000 ???? ; 7800.h 4 10000 ???? ; Version 1.0, 2019/12/13 5 10000 ???? 6 10000 ???? ; This file defines hardware registers and memory mapping for the 7 10000 ???? ; Atari 7800. It is distributed as a companion machine-specific support package 8 10000 ???? ; for the DASM compiler. Updates to this file, DASM, and associated tools are 9 10000 ???? ; available at https://github.com/dasm-assembler/dasm 10 10000 ???? 11 10000 ???? 12 10000 ???? ; ******************** 7800 Hardware Adresses *************************** 13 10000 ???? ; 14 10000 ???? ; MEMORY MAP USAGE OF THE 7800 15 10000 ???? ; 16 10000 ???? ; 00 - 1F TIA REGISTERS 17 10000 ???? ; 20 - 3F MARIA REGISTERS 18 10000 ???? ; 40 - FF RAM block 0 (zero page) 19 10000 ???? ; 100 - 11F TIA (mirror of 0000-001f) 20 10000 ???? ; 120 - 13F MARIA (mirror of 0020-003f) 21 10000 ???? ; 140 - 1FF RAM block 1 (stack) 22 10000 ???? ; 200 - 21F TIA (mirror of 0000-001f) 23 10000 ???? ; 220 - 23F MARIA (mirror of 0020-003f) 24 10000 ???? ; 240 - 27F ??? 25 10000 ???? ; 280 - 2FF RIOT I/O ports and timers 26 10000 ???? ; 300 - 31F TIA (mirror of 0000-001f) 27 10000 ???? ; 320 - 33F MARIA (mirror of 0020-003f) 28 10000 ???? ; 340 - 3FF ??? 29 10000 ???? ; 400 - 47F unused address space 30 10000 ???? ; 480 - 4FF RIOT RAM 31 10000 ???? ; 500 - 57F unused address space 32 10000 ???? ; 580 - 5FF RIOT RAM (mirror of 0480-04ff) 33 10000 ???? ; 600 - 17FF unused address space 34 10000 ???? ; 1800 - 203F RAM 35 10000 ???? ; 2040 - 20FF RAM block 0 (mirror of 0000-001f) 36 10000 ???? ; 2100 - 213F RAM 37 10000 ???? ; 2140 - 21FF RAM block 1 (mirror of 0140-01ff) 38 10000 ???? ; 2200 - 27FF RAM 39 10000 ???? ; 2800 - 2FFF mirror of 1800-27ff 40 10000 ???? ; 3000 - 3FFF unused address space 41 10000 ???? ; 4000 - FF7F potential cartridge address space 42 10000 ???? ; FF80 - FFF9 RESERVED FOR ENCRYPTION 43 10000 ???? ; FFFA - FFFF 6502 VECTORS 44 10000 ???? 45 10000 ???? 46 10000 ???? ;****** 00-1F ********* TIA REGISTERS ****************** 47 10000 ???? 48 10000 ???? 00 01 INPTCTRL = $01 ;Input control. In same address space as TIA. write-only 49 10000 ???? 00 01 VBLANK = $01 ;VBLANK. D7=1:dump paddle caps to ground. write-only 50 10000 ???? 00 08 INPT0 = $08 ;Paddle Control Input 0 read-only 51 10000 ???? 00 09 INPT1 = $09 ;Paddle Control Input 1 read-only 52 10000 ???? 00 0a INPT2 = $0A ;Paddle Control Input 2 read-only 53 10000 ???? 00 0b INPT3 = $0B ;Paddle Control Input 3 read-only 54 10000 ???? 55 10000 ???? ; ** some common alternate names for INPT0/1/2/3 56 10000 ???? 00 08 INPT4B = $08 ;Joystick 0 Fire 1 read-only 57 10000 ???? 00 09 INPT4A = $09 ;Joystick 0 Fire 1 read-only 58 10000 ???? 00 0a INPT5B = $0A ;Joystick 1 Fire 0 read-only 59 10000 ???? 00 0b INPT5A = $0B ;Joystick 1 Fire 1 read-only 60 10000 ???? 00 08 INPT4R = $08 ;Joystick 0 Fire 1 read-only 61 10000 ???? 00 09 INPT4L = $09 ;Joystick 0 Fire 1 read-only 62 10000 ???? 00 0a INPT5R = $0A ;Joystick 1 Fire 0 read-only 63 10000 ???? 00 0b INPT5L = $0B ;Joystick 1 Fire 1 read-only 64 10000 ???? 65 10000 ???? 00 0c INPT4 = $0C ;Player 0 Fire Button Input read-only 66 10000 ???? 00 0d INPT5 = $0D ;Player 1 Fire Button Input read-only 67 10000 ???? 68 10000 ???? 00 15 AUDC0 = $15 ;Audio Control Channel 0 write-only 69 10000 ???? 00 16 AUDC1 = $16 ;Audio Control Channel 1 write-only 70 10000 ???? 00 17 AUDF0 = $17 ;Audio Frequency Channel 0 write-only 71 10000 ???? 00 18 AUDF1 = $18 ;Audio Frequency Channel 1 write-only 72 10000 ???? 00 19 AUDV0 = $19 ;Audio Volume Channel 0 write-only 73 10000 ???? 00 1a AUDV1 = $1A ;Audio Volume Channel 1 write-only 74 10000 ???? 75 10000 ???? ;****** 20-3F ********* MARIA REGISTERS *************** 76 10000 ???? 77 10000 ???? 00 20 BACKGRND = $20 ;Background Color write-only 78 10000 ???? 00 21 P0C1 = $21 ;Palette 0 - Color 1 write-only 79 10000 ???? 00 22 P0C2 = $22 ;Palette 0 - Color 2 write-only 80 10000 ???? 00 23 P0C3 = $23 ;Palette 0 - Color 3 write-only 81 10000 ???? 00 24 WSYNC = $24 ;Wait For Sync write-only 82 10000 ???? 00 25 P1C1 = $25 ;Palette 1 - Color 1 write-only 83 10000 ???? 00 26 P1C2 = $26 ;Palette 1 - Color 2 write-only 84 10000 ???? 00 27 P1C3 = $27 ;Palette 1 - Color 3 write-only 85 10000 ???? 00 28 MSTAT = $28 ;Maria Status read-only 86 10000 ???? 00 29 P2C1 = $29 ;Palette 2 - Color 1 write-only 87 10000 ???? 00 2a P2C2 = $2A ;Palette 2 - Color 2 write-only 88 10000 ???? 00 2b P2C3 = $2B ;Palette 2 - Color 3 write-only 89 10000 ???? 00 2c DPPH = $2C ;Display List List Pointer High write-only 90 10000 ???? 00 2d P3C1 = $2D ;Palette 3 - Color 1 write-only 91 10000 ???? 00 2e P3C2 = $2E ;Palette 3 - Color 2 write-only 92 10000 ???? 00 2f P3C3 = $2F ;Palette 3 - Color 3 write-only 93 10000 ???? 00 30 DPPL = $30 ;Display List List Pointer Low write-only 94 10000 ???? 00 31 P4C1 = $31 ;Palette 4 - Color 1 write-only 95 10000 ???? 00 32 P4C2 = $32 ;Palette 4 - Color 2 write-only 96 10000 ???? 00 33 P4C3 = $33 ;Palette 4 - Color 3 write-only 97 10000 ???? 00 34 CHARBASE = $34 ;Character Base Address write-only 98 10000 ???? 00 34 CHBASE = $34 ;Character Base Address write-only 99 10000 ???? 00 35 P5C1 = $35 ;Palette 5 - Color 1 write-only 100 10000 ???? 00 36 P5C2 = $36 ;Palette 5 - Color 2 write-only 101 10000 ???? 00 37 P5C3 = $37 ;Palette 5 - Color 3 write-only 102 10000 ???? 00 38 OFFSET = $38 ;Unused - Store zero here write-only 103 10000 ???? 00 39 P6C1 = $39 ;Palette 6 - Color 1 write-only 104 10000 ???? 00 3a P6C2 = $3A ;Palette 6 - Color 2 write-only 105 10000 ???? 00 3b P6C3 = $3B ;Palette 6 - Color 3 write-only 106 10000 ???? 00 3c CTRL = $3C ;Maria Control Register write-only 107 10000 ???? 00 3d P7C1 = $3D ;Palette 7 - Color 1 write-only 108 10000 ???? 00 3e P7C2 = $3E ;Palette 7 - Color 2 write-only 109 10000 ???? 00 3f P7C3 = $3F ;Palette 7 - Color 3 write-only 110 10000 ???? 111 10000 ???? 112 10000 ???? ;****** 280-2FF ******* PIA PORTS AND TIMERS ************ 113 10000 ???? 114 10000 ???? 02 80 SWCHA = $280 ;P0+P1 Joystick Directional Input read-write 115 10000 ???? 02 81 CTLSWA = $281 ;I/O Control for SCHWA read-write 116 10000 ???? 02 81 SWACNT = $281 ;VCS name for above read-write 117 10000 ???? 02 82 SWCHB = $282 ;Console Switches read-write 118 10000 ???? 02 83 CTLSWB = $283 ;I/O Control for SCHWB read-write 119 10000 ???? 02 83 SWBCNT = $283 ;VCS name for above read-write 120 10000 ???? 121 10000 ???? 02 84 INTIM = $284 ;Interval Timer Read read-only 122 10000 ???? 02 94 TIM1T = $294 ;Set 1 CLK Interval (838 nsec/interval) write-only 123 10000 ???? 02 95 TIMINT = $295 ;Interval Timer Interrupt read-only 124 10000 ???? 02 95 TIM8T = $295 ;Set 8 CLK Interval (6.7 usec/interval) write-only 125 10000 ???? 02 96 TIM64T = $296 ;Set 64 CLK Interval (63.6 usec/interval) write-only 126 10000 ???? 02 97 T1024T = $297 ;Set 1024 CLK Interval (858.2 usec/interval) write-only 127 10000 ???? 02 9e TIM64TI = $29E ;Interrupt timer 64T write-only 128 10000 ???? 129 10000 ???? ;XM 130 10000 ???? 04 70 XCTRL = $470 ; 7=YM2151 6=RAM@6k 5=RAM@4k 4=pokey@450 3=hsc 2=cart 1=RoF_bank1 0=RoF_bank2 131 10000 ???? 04 70 XCTRL1 = $470 132 10000 ???? 04 78 XCTRL2 = $478 133 10000 ???? 04 7c XCTRL3 = $47c 134 10000 ???? 04 71 XCTRL4 = $471 135 10000 ???? 04 72 XCTRL5 = $472 136 10000 ???? 137 10000 ???? ; Pokey register relative locations, since its base may be different 138 10000 ???? ; depending on the hardware. 139 10000 ???? 00 00 PAUDF0 = $0 ; extra audio channels and frequencies 140 10000 ???? 00 01 PAUDC0 = $1 141 10000 ???? 00 02 PAUDF1 = $2 142 10000 ???? 00 03 PAUDC1 = $3 143 10000 ???? 00 04 PAUDF2 = $4 144 10000 ???? 00 05 PAUDC2 = $5 145 10000 ???? 00 06 PAUDF3 = $6 146 10000 ???? 00 07 PAUDC3 = $7 147 10000 ???? 00 08 PAUDCTL = $8 ; Audio Control 148 10000 ???? 00 09 PSTIMER = $9 149 10000 ???? 00 0a PRANDOM = $A ; 17 bit polycounter pseudo random 150 10000 ???? 00 0f PSKCTL = $F ; Serial Port control ------- FILE 7800basic.h ------- FILE 7800basic_variable_redefs.h LEVEL 3 PASS 3 0 10000 ???? include "7800basic_variable_redefs.h" 1 10000 ???? ; This file contains variable mapping and other information for the current project. 2 10000 ???? 3 10000 ???? 00 2a sfx_fire_length = .skipL035-sfx_fire 4 10000 ???? 5 10000 ???? 00 36 sfx_ding_length = .skipL034-sfx_ding 6 10000 ???? 7 10000 ???? 01 41 controller_button2_press_bit4 = var1 8 10000 ???? 9 10000 ???? 01 41 controller_button1_press_bit1 = var1 10 10000 ???? 11 10000 ???? 01 41 controller_button_debounce_bit0 = var1 12 10000 ???? 13 10000 ???? 01 41 controllerButtonState = var1 14 10000 ???? 15 10000 ???? 01 40 controller_down_bit4 = var0 16 10000 ???? 17 10000 ???? 01 40 controller_up_bit3 = var0 18 10000 ???? 19 10000 ???? 01 40 controller_right_bit2 = var0 20 10000 ???? 21 10000 ???? 01 40 controller_left_bit1 = var0 22 10000 ???? 23 10000 ???? 01 40 controller_debounce_bit0 = var0 24 10000 ???? 25 10000 ???? 01 40 controllerState = var0 26 10000 ???? 27 10000 ???? 00 01 ROM48K = 1 ------- FILE 7800basic.h 6 10000 ???? 7 10000 ???? ;************ 7800 overall RAM map ************** 8 10000 ???? 9 10000 ???? ; 40-FF zero page RAM 10 10000 ???? ; 140-1FF RAM (stack) 11 10000 ???? ; 1800-203F RAM 12 10000 ???? ; 2100-213F RAM 13 10000 ???? ; 2200-27FF RAM 14 10000 ???? 15 10000 ???? ;************ 7800basic RAM usage map ************** 16 10000 ???? 17 10000 ???? ; 40-FF numerous defines, listed below 18 10000 ???? ; 140-1FF RAM (stack) 19 10000 ???? 20 10000 ???? ; 1800-187F DLL (1800-18DF with page flipping enabled) 21 10000 ???? ; 1880-1FFF DLs (18E0-1FFF with page flipping enabled) 22 10000 ???? 23 10000 ???? ; 2000-203F Reserved 24 10000 ???? ; 2100-213F Reserved 25 10000 ???? ; 2200-27FF Free 26 10000 ???? 27 10000 ???? 1f e0 eeprombuffer = $1FE0 28 10000 ???? 18 00 DLLMEM = $1800 29 10000 ???? 00 70 DBOFFSET = $70 ; $E0 length DL is /2 for double-buffering 30 10000 ???? 31 10000 ???? - ifconst PLOTVALUEPAGE 32 10000 ???? -VALBUFFER = (PLOTVALUEPAGE*256) 33 10000 ???? else 34 10000 ???? 20 00 VALBUFFER = $2000 ; to $203F ** never let VALBUFFER straddle pages 35 10000 ???? endif 36 10000 ???? 37 10000 ???? 38 10000 ???? 21 00 pausestate = $2100 39 10000 ???? 21 01 dlzero = $2101 ; zero to force end of $2100 DL, which we use in vblank and overscan 40 10000 ???? 21 02 sINPT1 = $2102 ; save register for joy button joy0 41 10000 ???? 21 03 sINPT3 = $2103 ; save register for joy button joy1 42 10000 ???? 21 04 currentbank = $2104 43 10000 ???? 44 10000 ???? 21 05 currentrambank = $2105 45 10000 ???? 21 06 charactermode = $2106 46 10000 ???? 21 07 sCTRL = $2107 47 10000 ???? 21 08 pokeydetected = $2108 48 10000 ???? 21 09 paldetected = $2109 49 10000 ???? 21 0a avoxdetected = $210A 50 10000 ???? 21 0b sCHARBASE = $210B ; save register for CHARBASE 51 10000 ???? 52 10000 ???? 21 0c hsdevice = $210C 53 10000 ???? 21 0d hsdifficulty = $210D 54 10000 ???? 21 0e hserror = $210E 55 10000 ???? 21 0f hsgameslot = $210F 56 10000 ???? 21 10 hsnewscoreline = $2110 57 10000 ???? 21 11 hsnewscorerank = $2111 58 10000 ???? 21 12 HSRAMTable = $2112 ; to $212F (30 bytes) Format: III*5, SSS*5 59 10000 ???? 21 12 HSRAMInitials = $2112 ; see above 60 10000 ???? 21 21 HSRAMScores = $2121 ; see above 61 10000 ???? 62 10000 ???? 21 31 ssCTRL = $2131 63 10000 ???? 21 32 ssCHARBASE = $2132 64 10000 ???? 21 33 hsdisplaymode = $2133 65 10000 ???? 21 34 gamedifficulty = $2134 66 10000 ???? 21 35 hsinitialpos = $2135 67 10000 ???? 21 36 hsinitialhold = $2136 68 10000 ???? 21 37 hscursorx = $2137 69 10000 ???? 21 38 hsjoydebounce = $2138 70 10000 ???? 21 39 hsswcha = $2139 71 10000 ???? 21 3a hsinpt1 = $213A 72 10000 ???? 21 3b hscolorchaseindex = $213B 73 10000 ???? 21 3c visibleDLLstart = $213C 74 10000 ???? 21 3d overscanDLLstart = $213D 75 10000 ???? 21 3e frameslost = $213E 76 10000 ???? 77 10000 ???? 78 10000 ???? 00 40 rand = $40 79 10000 ???? 00 41 rand16 = $41 80 10000 ???? 00 42 temp1 = $42 81 10000 ???? 00 43 temp2 = $43 82 10000 ???? 00 44 temp3 = $44 83 10000 ???? 00 45 temp4 = $45 84 10000 ???? 00 46 temp5 = $46 85 10000 ???? 00 47 temp6 = $47 86 10000 ???? 00 48 temp7 = $48 87 10000 ???? 00 49 temp8 = $49 88 10000 ???? 00 4a temp9 = $4a 89 10000 ???? 90 10000 ???? 00 4b pokeybase = $4b 91 10000 ???? 00 4b pokeybaselo = $4b 92 10000 ???? 00 4c pokeybasehi = $4c 93 10000 ???? 94 10000 ???? 00 4d visibleover = $4d 95 10000 ???? 96 10000 ???? 00 4e sfx1pointlo = $4e 97 10000 ???? 00 4f sfx2pointlo = $4f 98 10000 ???? 00 50 sfx1pointhi = $50 99 10000 ???? 00 51 sfx2pointhi = $51 100 10000 ???? 101 10000 ???? 00 52 sfx1priority = $52 102 10000 ???? 00 53 sfx2priority = $53 103 10000 ???? 00 54 sfx1poffset = $54 104 10000 ???? 00 55 sfx2poffset = $55 105 10000 ???? 106 10000 ???? 00 56 sfx1frames = $56 107 10000 ???? 00 57 sfx2frames = $57 108 10000 ???? 00 58 sfx1tick = $58 109 10000 ???? 00 59 sfx2tick = $59 110 10000 ???? 111 10000 ???? 00 5a tempmath = $5a 112 10000 ???? 113 10000 ???? 00 5b pokey1pointlo = $5b 114 10000 ???? 00 5c pokey1pointhi = $5c 115 10000 ???? 00 5d pokey2pointlo = $5d 116 10000 ???? 00 5e pokey2pointhi = $5e 117 10000 ???? 00 5f pokey3pointlo = $5f 118 10000 ???? 00 60 pokey3pointhi = $60 119 10000 ???? 00 61 pokey4pointlo = $61 120 10000 ???? 00 62 pokey4pointhi = $62 121 10000 ???? 122 10000 ???? 00 63 dlpnt = $63 ; to $64 123 10000 ???? 00 65 dlend = $65 ; to $81 - for 28 possible visible dll entries 124 10000 ???? 00 82 dlendsave = $82 ; to $9e - for 28 possible visible dll entries 125 10000 ???? 126 10000 ???? 00 9f speech_addr = $9f 127 10000 ???? 00 a0 speech_addr_hi = $a0 128 10000 ???? 129 10000 ???? 00 a1 HSGameTableLo = $a1 130 10000 ???? 00 a2 HSGameTableHi = $a2 131 10000 ???? 00 a3 HSVoxHi = $a3 132 10000 ???? 00 a4 HSVoxLo = $a4 133 10000 ???? 134 10000 ???? ;channel pointers 135 10000 ???? 136 10000 ???? 00 a5 songchannel1layer1lo = $a5 137 10000 ???? 00 a6 songchannel2layer1lo = $a6 138 10000 ???? 00 a7 songchannel3layer1lo = $a7 139 10000 ???? 00 a8 songchannel4layer1lo = $a8 140 10000 ???? 141 10000 ???? 00 a9 songchannel1layer2lo = $a9 142 10000 ???? 00 aa songchannel2layer2lo = $aA 143 10000 ???? 00 ab songchannel3layer2lo = $aB 144 10000 ???? 00 ac songchannel4layer2lo = $aC 145 10000 ???? 146 10000 ???? 00 ad songchannel1layer3lo = $aD 147 10000 ???? 00 ae songchannel2layer3lo = $aE 148 10000 ???? 00 af songchannel3layer3lo = $aF 149 10000 ???? 00 b0 songchannel4layer3lo = $b0 150 10000 ???? 151 10000 ???? 00 b1 songchannel1layer1hi = $b1 152 10000 ???? 00 b2 songchannel2layer1hi = $b2 153 10000 ???? 00 b3 songchannel3layer1hi = $b3 154 10000 ???? 00 b4 songchannel4layer1hi = $b4 155 10000 ???? 156 10000 ???? 00 b5 songchannel1layer2hi = $b5 157 10000 ???? 00 b6 songchannel2layer2hi = $b6 158 10000 ???? 00 b7 songchannel3layer2hi = $b7 159 10000 ???? 00 b8 songchannel4layer2hi = $b8 160 10000 ???? 161 10000 ???? 00 b9 songchannel1layer3hi = $b9 162 10000 ???? 00 ba songchannel2layer3hi = $bA 163 10000 ???? 00 bb songchannel3layer3hi = $bB 164 10000 ???? 00 bc songchannel4layer3hi = $bC 165 10000 ???? 166 10000 ???? 00 bd songdatalo = $bd 167 10000 ???? 00 be songdatahi = $be 168 10000 ???? 169 10000 ???? 00 bf inactivechannelcount = $bf 170 10000 ???? 171 10000 ???? 172 10000 ???? 00 c0 songchannel1transpose = $c0 173 10000 ???? 00 c1 songchannel2transpose = $c1 174 10000 ???? 00 c2 songchannel3transpose = $c2 175 10000 ???? 00 c3 songchannel4transpose = $c3 176 10000 ???? 177 10000 ???? 00 c4 songstackindex = $c4 178 10000 ???? 179 10000 ???? 00 c5 songchannel1instrumentlo = $c5 180 10000 ???? 00 c6 songchannel2instrumentlo = $c6 181 10000 ???? 00 c7 songchannel3instrumentlo = $c7 182 10000 ???? 00 c8 songchannel4instrumentlo = $c8 183 10000 ???? 184 10000 ???? 00 c9 songchannel1instrumenthi = $c9 185 10000 ???? 00 ca songchannel2instrumenthi = $ca 186 10000 ???? 00 cb songchannel3instrumenthi = $cb 187 10000 ???? 00 cc songchannel4instrumenthi = $cc 188 10000 ???? 189 10000 ???? 00 cd sfx1notedata = $cd 190 10000 ???? 00 ce sfx2notedata = $ce 191 10000 ???? 192 10000 ???? 00 cf songloops = $cf 193 10000 ???? 194 10000 ???? 00 d0 songpointerlo = $D0 195 10000 ???? 00 d1 songpointerhi = $D1 196 10000 ???? 197 10000 ???? 00 d2 voxlock = $D2 198 10000 ???? 00 d3 voxqueuesize = $D3 199 10000 ???? 200 10000 ???? 00 d4 vblankroutines = $D4 201 10000 ???? 202 10000 ???? 00 d5 doublebufferstate = $D5 203 10000 ???? 00 d6 doublebufferdloffset = $D6 204 10000 ???? 00 d7 doublebufferbufferdirty = $D7 205 10000 ???? 206 10000 ???? 00 d8 inttemp1 = $D8 207 10000 ???? 00 d9 inttemp2 = $D9 208 10000 ???? 00 da inttemp3 = $DA 209 10000 ???? 00 db inttemp4 = $DB 210 10000 ???? 00 dc inttemp5 = $DC 211 10000 ???? 00 dd inttemp6 = $DD 212 10000 ???? 213 10000 ???? 00 de sfxschedulelock = $DE 214 10000 ???? 00 df sfxschedulemissed = $DF 215 10000 ???? 00 e0 sfxinstrumentlo = $E0 216 10000 ???? 00 e1 sfxinstrumenthi = $E1 217 10000 ???? 00 e2 sfxpitchoffset = $E2 218 10000 ???? 00 e3 sfxnoteindex = $E3 219 10000 ???? 220 10000 ???? 00 e4 CTLSWAs = $E4 221 10000 ???? 00 e5 CTLSWBs = $E5 222 10000 ???? 223 10000 ???? 00 e6 A = $e6 224 10000 ???? 00 e6 a = $e6 225 10000 ???? 00 e7 B = $e7 226 10000 ???? 00 e7 b = $e7 227 10000 ???? 00 e8 C = $e8 228 10000 ???? 00 e8 c = $e8 229 10000 ???? 00 e9 D = $e9 230 10000 ???? 00 e9 d = $e9 231 10000 ???? 00 ea E = $ea 232 10000 ???? 00 ea e = $ea 233 10000 ???? 00 eb F = $eb 234 10000 ???? 00 eb f = $eb 235 10000 ???? 00 ec G = $ec 236 10000 ???? 00 ec g = $ec 237 10000 ???? 00 ed H = $ed 238 10000 ???? 00 ed h = $ed 239 10000 ???? 00 ee I = $ee 240 10000 ???? 00 ee i = $ee 241 10000 ???? 00 ef J = $ef 242 10000 ???? 00 ef j = $ef 243 10000 ???? 00 f0 K = $f0 244 10000 ???? 00 f0 k = $f0 245 10000 ???? 00 f1 L = $f1 246 10000 ???? 00 f1 l = $f1 247 10000 ???? 00 f2 M = $f2 248 10000 ???? 00 f2 m = $f2 249 10000 ???? 00 f3 N = $f3 250 10000 ???? 00 f3 n = $f3 251 10000 ???? 00 f4 O = $f4 252 10000 ???? 00 f4 o = $f4 253 10000 ???? 00 f5 P = $f5 254 10000 ???? 00 f5 p = $f5 255 10000 ???? 00 f6 Q = $f6 256 10000 ???? 00 f6 q = $f6 257 10000 ???? 00 f7 R = $f7 258 10000 ???? 00 f7 r = $f7 259 10000 ???? 00 f8 S = $f8 260 10000 ???? 00 f8 s = $f8 261 10000 ???? 00 f9 T = $f9 262 10000 ???? 00 f9 t = $f9 263 10000 ???? 00 fa U = $fa 264 10000 ???? 00 fa u = $fa 265 10000 ???? 00 fb V = $fb 266 10000 ???? 00 fb v = $fb 267 10000 ???? 00 fc W = $fc 268 10000 ???? 00 fc w = $fc 269 10000 ???? 00 fd X = $fd 270 10000 ???? 00 fd x = $fd 271 10000 ???? 00 fe Y = $fe 272 10000 ???? 00 fe y = $fe 273 10000 ???? 00 ff Z = $ff 274 10000 ???? 00 ff z = $ff 275 10000 ???? 276 10000 ???? ; var0-var99 variables use the top of the stack 277 10000 ???? 01 40 var0 = $140 278 10000 ???? 01 41 var1 = $141 279 10000 ???? 01 42 var2 = $142 280 10000 ???? 01 43 var3 = $143 281 10000 ???? 01 44 var4 = $144 282 10000 ???? 01 45 var5 = $145 283 10000 ???? 01 46 var6 = $146 284 10000 ???? 01 47 var7 = $147 285 10000 ???? 01 48 var8 = $148 286 10000 ???? 01 49 var9 = $149 287 10000 ???? 01 4a var10 = $14a 288 10000 ???? 01 4b var11 = $14b 289 10000 ???? 01 4c var12 = $14c 290 10000 ???? 01 4d var13 = $14d 291 10000 ???? 01 4e var14 = $14e 292 10000 ???? 01 4f var15 = $14f 293 10000 ???? 01 50 var16 = $150 294 10000 ???? 01 51 var17 = $151 295 10000 ???? 01 52 var18 = $152 296 10000 ???? 01 53 var19 = $153 297 10000 ???? 01 54 var20 = $154 298 10000 ???? 01 55 var21 = $155 299 10000 ???? 01 56 var22 = $156 300 10000 ???? 01 57 var23 = $157 301 10000 ???? 01 58 var24 = $158 302 10000 ???? 01 59 var25 = $159 303 10000 ???? 01 5a var26 = $15a 304 10000 ???? 01 5b var27 = $15b 305 10000 ???? 01 5c var28 = $15c 306 10000 ???? 01 5d var29 = $15d 307 10000 ???? 01 5e var30 = $15e 308 10000 ???? 01 5f var31 = $15f 309 10000 ???? 01 60 var32 = $160 310 10000 ???? 01 61 var33 = $161 311 10000 ???? 01 62 var34 = $162 312 10000 ???? 01 63 var35 = $163 313 10000 ???? 01 64 var36 = $164 314 10000 ???? 01 65 var37 = $165 315 10000 ???? 01 66 var38 = $166 316 10000 ???? 01 67 var39 = $167 317 10000 ???? 01 68 var40 = $168 318 10000 ???? 01 69 var41 = $169 319 10000 ???? 01 6a var42 = $16a 320 10000 ???? 01 6b var43 = $16b 321 10000 ???? 01 6c var44 = $16c 322 10000 ???? 01 6d var45 = $16d 323 10000 ???? 01 6e var46 = $16e 324 10000 ???? 01 6f var47 = $16f 325 10000 ???? 01 70 var48 = $170 326 10000 ???? 01 71 var49 = $171 327 10000 ???? 01 72 var50 = $172 328 10000 ???? 01 73 var51 = $173 329 10000 ???? 01 74 var52 = $174 330 10000 ???? 01 75 var53 = $175 331 10000 ???? 01 76 var54 = $176 332 10000 ???? 01 77 var55 = $177 333 10000 ???? 01 78 var56 = $178 334 10000 ???? 01 79 var57 = $179 335 10000 ???? 01 7a var58 = $17a 336 10000 ???? 01 7b var59 = $17b 337 10000 ???? 01 7c var60 = $17c 338 10000 ???? 01 7d var61 = $17d 339 10000 ???? 01 7e var62 = $17e 340 10000 ???? 01 7f var63 = $17f 341 10000 ???? 01 80 var64 = $180 342 10000 ???? 01 81 var65 = $181 343 10000 ???? 01 82 var66 = $182 344 10000 ???? 01 83 var67 = $183 345 10000 ???? 01 84 var68 = $184 346 10000 ???? 01 85 var69 = $185 347 10000 ???? 01 86 var70 = $186 348 10000 ???? 01 87 var71 = $187 349 10000 ???? 01 88 var72 = $188 350 10000 ???? 01 89 var73 = $189 351 10000 ???? 01 8a var74 = $18a 352 10000 ???? 01 8b var75 = $18b 353 10000 ???? 01 8c var76 = $18c 354 10000 ???? 01 8d var77 = $18d 355 10000 ???? 01 8e var78 = $18e 356 10000 ???? 01 8f var79 = $18f 357 10000 ???? 01 90 var80 = $190 358 10000 ???? 01 91 var81 = $191 359 10000 ???? 01 92 var82 = $192 360 10000 ???? 01 93 var83 = $193 361 10000 ???? 01 94 var84 = $194 362 10000 ???? 01 95 var85 = $195 363 10000 ???? 01 96 var86 = $196 364 10000 ???? 01 97 var87 = $197 365 10000 ???? 01 98 var88 = $198 366 10000 ???? 01 99 var89 = $199 367 10000 ???? 01 9a var90 = $19a 368 10000 ???? 01 9b var91 = $19b 369 10000 ???? 01 9c var92 = $19c 370 10000 ???? 01 9d var93 = $19d 371 10000 ???? 01 9e var94 = $19e 372 10000 ???? 01 9f var95 = $19f 373 10000 ???? 01 a0 var96 = $1a0 374 10000 ???? 01 a1 var97 = $1a1 375 10000 ???? 01 a2 var98 = $1a2 376 10000 ???? 01 a3 var99 = $1a3 377 10000 ???? 378 U01c2 ???? SEG.U "7800basicRAM" 379 U01a4 ORG $1A4 380 U01a4 381 U01a4 ; MAX allocation locations are in comments... 382 U01a4 00 framecounter DS 1 ; $1A4 383 U01a5 00 countdownseconds DS 1 ; $1A5 384 U01a6 00 00 00 score0 DS 3 ; $1A6 $1A7 $1A8 385 U01a9 00 00 00 score1 DS 3 ; $1A9 $1AA $1AB 386 U01ac 00 pausebuttonflag DS 1 ; $1AC 387 U01ad 00 valbufend DS 1 ; $1AD 388 U01ae 00 valbufendsave DS 1 ; $1AE 389 U01af 00 finescrollx DS 1 ; $1AF 390 U01b0 00 finescrolly DS 1 ; $1B0 391 U01b1 00 joybuttonmode DS 1 ; $1B1 ; track joysticks that were changed to one-button mode 392 U01b2 00 interruptindex DS 1 ; $1B2 393 U01b3 394 U01b3 - ifconst DOUBLEBUFFER 395 U01b3 -doublebufferminimumframetarget DS 1 ; $1B3 396 U01b3 -doublebufferminimumframeindex DS 1 ; $1B4 397 U01b3 endif 398 U01b3 399 U01b3 00 pausedisable DS 1 ; $1B5 400 U01b4 00 XCTRL1s DS 1 ; $1B6 401 U01b5 402 U01b5 - ifconst AVOXVOICE 403 U01b5 -avoxenable DS 1 ; $1B7 404 U01b5 -tempavox DS 1 ; $1B8 405 U01b5 endif 406 U01b5 407 U01b5 - ifconst MUSICTRACKER 408 U01b5 -songtempo DS 1 ; $1B9 409 U01b5 -songtick DS 1 ; $1BA 410 U01b5 - 411 U01b5 -songchannel1layer1loops DS 1 ; $1BB 412 U01b5 -songchannel2layer1loops DS 1 ; $1BC 413 U01b5 -songchannel3layer1loops DS 1 ; $1BD 414 U01b5 -songchannel4layer1loops DS 1 ; $1BE 415 U01b5 - 416 U01b5 -songchannel1layer2loops DS 1 ; $1BF 417 U01b5 -songchannel2layer2loops DS 1 ; $1C0 418 U01b5 -songchannel3layer2loops DS 1 ; $1C1 419 U01b5 -songchannel4layer2loops DS 1 ; $1C2 420 U01b5 - 421 U01b5 -songchannel1layer3loops DS 1 ; $1C3 422 U01b5 -songchannel2layer3loops DS 1 ; $1C4 423 U01b5 -songchannel3layer3loops DS 1 ; $1C5 424 U01b5 -songchannel4layer3loops DS 1 ; $1C6 425 U01b5 - 426 U01b5 -songchannel1busywait DS 1 ; $1C7 427 U01b5 -songchannel2busywait DS 1 ; $1C8 428 U01b5 -songchannel3busywait DS 1 ; $1C9 429 U01b5 -songchannel4busywait DS 1 ; $1CA 430 U01b5 - 431 U01b5 -songchannel1stackdepth DS 1 ; $1CB 432 U01b5 -songchannel2stackdepth DS 1 ; $1CC 433 U01b5 -songchannel3stackdepth DS 1 ; $1CD 434 U01b5 -songchannel4stackdepth DS 1 ; $1CE 435 U01b5 endif 436 U01b5 437 U01b5 00 palframes DS 1 ; $1CF 438 U01b6 00 palfastframe DS 1 ; $1D0 439 U01b7 440 U01b7 - ifconst MOUSESUPPORT 441 U01b7 -port0resolution DS 1 ; $1D1 442 U01b7 -port1resolution DS 1 ; $1D2 443 U01b7 else 444 U01b7 - ifconst TRAKBALLSUPPORT 445 U01b7 -port0resolution DS 1 ; $1D1 446 U01b7 -port1resolution DS 1 ; $1D2 447 U01b7 endif 448 U01b7 endif 449 U01b7 450 U01b7 00 port0control DS 1 ; $1D3 451 U01b8 00 port1control DS 1 ; $1D4 452 U01b9 453 U01b9 ; port#control values... 454 U01b9 ; 1 = proline 455 U01b9 ; 2 = lightgun 456 U01b9 ; 3 = paddle 457 U01b9 ; 4 = trakball 458 U01b9 ; 5 = vcs joystick 459 U01b9 ; 6 = driving 460 U01b9 ; 7 = keypad 461 U01b9 ; 8 = st mouse/cx80 462 U01b9 ; 9 = amiga mouse 463 U01b9 ; 10 = atarivox 464 U01b9 465 U01b9 ; controller 0 data... 466 U01b9 00 paddleposition0 DS 1 ; $1D5 467 U01b9 01 b9 keypadmatrix0a = paddleposition0 468 U01b9 01 b9 drivingposition0 = paddleposition0 469 U01b9 01 b9 trakballx0 = paddleposition0 470 U01b9 01 b9 mousex0 = paddleposition0 471 U01b9 01 b9 lighttgunx0 = paddleposition0 472 U01ba 473 U01ba ; controller 1 data... 474 U01ba 00 paddleposition2 DS 1 ; $1D6 475 U01ba 01 ba keypadmatrix1a = paddleposition2 476 U01ba 01 ba drivingposition1 = paddleposition2 477 U01ba 01 ba trakballx1 = paddleposition2 478 U01ba 01 ba mousex1 = paddleposition2 479 U01ba 01 ba lightgunx1 = paddleposition2 480 U01bb 481 U01bb ; controller 0 altdata... 482 U01bb 00 paddleposition1 DS 1 ; $1D7 483 U01bb 01 bb keypadmatrix0b = paddleposition1 484 U01bb 01 bb trakbally0 = paddleposition1 485 U01bb 01 bb mousey0 = paddleposition1 486 U01bb 01 bb lightguny0 = paddleposition1 487 U01bc 488 U01bc ; controller 1 altdata... 489 U01bc 00 paddleposition3 DS 1 ; $1D8 490 U01bc 01 bc keypadmatrix1b = paddleposition3 491 U01bc 01 bc trakbally1 = paddleposition3 492 U01bc 01 bc mousey1 = paddleposition3 493 U01bc 01 bc lightguny1 = paddleposition3 494 U01bd 495 U01bd ; controller state save. for trakball state+dir codes, rotary position codes 496 U01bd 00 controller0statesave DS 1 ; $1D9 497 U01bd 01 bd paddleprevious0 = controller0statesave 498 U01bd 01 bd mousecodex0 = controller0statesave 499 U01bd 01 bd trakballcodex0 = controller0statesave 500 U01bd 01 bd keypadmatrix0c = controller0statesave 501 U01be 502 U01be 00 controller1statesave DS 1 ; $1DA 503 U01be 01 be paddleprevious2 = controller1statesave 504 U01be 01 be mousecodex1 = controller1statesave 505 U01be 01 be trakballcodex1 = controller1statesave 506 U01be 01 be keypadmatrix1c = controller1statesave 507 U01bf 508 U01bf 00 paddleprevious1 DS 1 ; $1DB 509 U01bf 01 bf keypadmatrix0d = paddleprevious1 510 U01bf 01 bf mousecodey0 = paddleprevious1 511 U01bf 01 bf trakballcodey0 = paddleprevious1 512 U01c0 513 U01c0 00 paddleprevious3 DS 1 ; $1DC 514 U01c0 01 c0 keypadmatrix1d = paddleprevious3 515 U01c0 01 c0 mousecodey1 = paddleprevious3 516 U01c0 01 c0 trakballcodey1 = paddleprevious3 517 U01c1 518 U01c1 - ifconst pokeysupport 519 U01c1 -pokey1frames DS 1 ; $1DD 520 U01c1 -pokey1tick DS 1 ; $1DE 521 U01c1 -pokey2frames DS 1 ; $1DF 522 U01c1 -pokey2tick DS 1 ; $1E0 523 U01c1 -pokey3frames DS 1 ; $1E1 524 U01c1 -pokey3tick DS 1 ; $1E2 525 U01c1 -pokey4frames DS 1 ; $1E3 526 U01c1 -pokey4tick DS 1 ; $1E4 527 U01c1 -pokey1priority DS 1 ; $1E5 528 U01c1 -pokey1offset DS 1 ; $1E6 529 U01c1 -pokey2priority DS 1 ; $1E7 530 U01c1 -pokey2offset DS 1 ; $1E8 531 U01c1 -pokey3priority DS 1 ; $1E9 532 U01c1 -pokey3offset DS 1 ; $1EA 533 U01c1 -pokey4priority DS 1 ; $1EB 534 U01c1 -pokey4offset DS 1 ; $1EC 535 U01c1 endif 536 U01c1 537 U01c1 ifnconst CANARYOFF 538 U01c1 00 canary DS 1 ; $1ED 539 U01c2 endif 540 U01c2 541 U01c2 ifnconst bankswitchmode stack allowance: 30 nested subroutines. 542 U01c2 echo " stack allowance:",[($1FF - .)/2]d,"nested subroutines." 543 U01c2 - else 544 U01c2 - echo " stack allowance:",[($1FF - .)/3]d,"nested subroutines." 545 U01c2 endif 546 U01c2 ifnconst CANARYOFF the canary is situated at: $1c1 547 U01c2 echo " the canary is situated at:",[canary] 548 U01c2 - else 549 U01c2 - echo " the canary is disabled." 550 U01c2 endif 551 U01c2 552 U01c2 ; $1EE - $1FF reserved for stack 553 U01c2 554 10000 ???? SEG "GAME" 555 10000 ???? ------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm ------- FILE 7800basic_variable_redefs.h LEVEL 2 PASS 3 0 10000 ???? include "7800basic_variable_redefs.h" 1 10000 ???? ; This file contains variable mapping and other information for the current project. 2 10000 ???? 3 10000 ???? 00 2a sfx_fire_length = .skipL035-sfx_fire 4 10000 ???? 5 10000 ???? 00 36 sfx_ding_length = .skipL034-sfx_ding 6 10000 ???? 7 10000 ???? 01 41 controller_button2_press_bit4 = var1 8 10000 ???? 9 10000 ???? 01 41 controller_button1_press_bit1 = var1 10 10000 ???? 11 10000 ???? 01 41 controller_button_debounce_bit0 = var1 12 10000 ???? 13 10000 ???? 01 41 controllerButtonState = var1 14 10000 ???? 15 10000 ???? 01 40 controller_down_bit4 = var0 16 10000 ???? 17 10000 ???? 01 40 controller_up_bit3 = var0 18 10000 ???? 19 10000 ???? 01 40 controller_right_bit2 = var0 20 10000 ???? 21 10000 ???? 01 40 controller_left_bit1 = var0 22 10000 ???? 23 10000 ???? 01 40 controller_debounce_bit0 = var0 24 10000 ???? 25 10000 ???? 01 40 controllerState = var0 26 10000 ???? 27 10000 ???? 00 01 ROM48K = 1 ------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm 545 10000 ???? 546 10000 ???? ; A BEAD header gets automatically incorportated into the ROM header. 547 10000 ???? ; For more BEAD executable info, check out the spec... 548 10000 ???? ; http://7800.8bitdev.org/index.php/The_Atari_7800_BEAD_Execuable_Specification 549 10000 ???? 550 10000 ???? 00 01 GAMEDESCRIPTIONSET = 1 551 10000 ???? 4e 61 6d 65 GAMEDESCRIPTION = "Test Name" 552 10000 ???? 553 10000 ???? 00 40 BDHSC = %01000000 554 10000 ???? 00 20 BDYM = %00100000 555 10000 ???? 00 10 BDPOKEY = %00010000 556 10000 ???? 00 08 BDROF = %00001000 557 10000 ???? 00 00 BD16K = %00000000 558 10000 ???? 00 01 BD32K = %00000001 559 10000 ???? 00 02 BD48K = %00000010 560 10000 ???? 00 05 BD1800 = %00000101 561 10000 ???? 00 06 BD4000 = %00000110 562 10000 ???? 563 10000 ???? - ifconst ROM16K 564 10000 ???? -BEADHEADER = 1 565 10000 ???? endif 566 10000 ???? - ifconst ROM32K 567 10000 ???? -BEADHEADER = 1 568 10000 ???? endif 569 10000 ???? ifconst ROM48K 570 10000 ???? 00 01 BEADHEADER = 1 571 10000 ???? endif 572 10000 ???? 573 10000 ???? ifconst BEADHEADER 574 10000 ???? BEADHARDWARE SET 0 575 10000 ???? - ifconst ROM16K 576 10000 ???? -BEADHARDWARE SET (BEADHARDWARE|BD16K) 577 10000 ???? endif 578 10000 ???? - ifconst ROM32K 579 10000 ???? -BEADHARDWARE SET (BEADHARDWARE|BD32K) 580 10000 ???? endif 581 10000 ???? ifconst ROM48K 582 10000 ???? BEADHARDWARE SET (BEADHARDWARE|BD48K) 583 10000 ???? endif 584 10000 ???? - ifconst pokeysupport 585 10000 ???? -BEADHARDWARE SET (BEADHARDWARE|BDPOKEY) 586 10000 ???? endif 587 10000 ???? - ifconst HSSUPPORT 588 10000 ???? -BEADHARDWARE SET (BEADHARDWARE|BDHSC) 589 10000 ???? endif 590 10000 ???? endif 591 10000 ???? 592 10000 ???? ;start address of cart... 593 10000 ???? ifconst ROM48K 594 4000 ORG $4000,0 595 4000 ifconst BEADHEADER 596 4000 be ad 02 .byte.b $BE,$AD,BEADHARDWARE 597 4003 ifconst GAMEDESCRIPTIONSET 598 4003 18 CLC 599 4004 90 0a BCC _SKIPDESCRIPTION 600 4006 54 65 73 74* .byte.b GAMEDESCRIPTION,0 601 4010 _SKIPDESCRIPTION 602 4010 endif 603 4010 6c fc ff jmp ($FFFC) 604 4013 endif 605 4013 - else 606 4013 - ifconst bankswitchmode 607 4013 - ifconst ROMAT4K 608 4013 - ORG $4000,0 609 4013 - RORG $4000 610 4013 - else 611 4013 - ORG $8000,0 612 4013 - RORG $8000 613 4013 - endif 614 4013 - else ; not bankswitchmode 615 4013 - ifconst ROM16K 616 4013 - ORG $C000,0 617 4013 - ifconst BEADHEADER 618 4013 - .byte $BE,$AD,BEADHARDWARE 619 4013 - ifconst GAMEDESCRIPTION 620 4013 - CLC 621 4013 - BCC _SKIPDESCRIPTION 622 4013 - .byte GAMEDESCRIPTION,0 623 4013 -_SKIPDESCRIPTION 624 4013 - endif 625 4013 - jmp ($FFFC) 626 4013 - endif 627 4013 - else 628 4013 - ifconst ROM8K 629 4013 - ORG $E000,0 630 4013 - else 631 4013 - ORG $8000,0 632 4013 - ifconst BEADHEADER 633 4013 - .byte $BE,$AD,BEADHARDWARE 634 4013 - ifconst GAMEDESCRIPTION 635 4013 - CLC 636 4013 - BCC _SKIPDESCRIPTION 637 4013 - .byte GAMEDESCRIPTION,0 638 4013 -_SKIPDESCRIPTION 639 4013 - endif 640 4013 - jmp ($FFFC) 641 4013 - endif 642 4013 - endif 643 4013 - endif 644 4013 - endif 645 4013 endif 646 4013 647 4013 ;7800basic v0.16 Nov 21 2020 15:38:52 648 4013 SPACEOVERFLOW SET 0 649 4013 game 650 4013 .L00 ;; set romsize 48k 651 4013 652 4013 . 653 4013 ;; 654 4013 655 4013 .L01 ;; dim controllerState = var0 656 4013 657 4013 .L02 ;; dim controller_debounce_bit0 = var0 658 4013 659 4013 .L03 ;; dim controller_left_bit1 = var0 660 4013 661 4013 .L04 ;; dim controller_right_bit2 = var0 662 4013 663 4013 .L05 ;; dim controller_up_bit3 = var0 664 4013 665 4013 .L06 ;; dim controller_down_bit4 = var0 666 4013 667 4013 .L07 ;; dim controllerButtonState = var1 668 4013 669 4013 .L08 ;; dim controller_button_debounce_bit0 = var1 670 4013 671 4013 .L09 ;; dim controller_button1_press_bit1 = var1 672 4013 673 4013 .L010 ;; dim controller_button2_press_bit4 = var1 674 4013 675 4013 . 676 4013 ;; 677 4013 678 4013 . 679 4013 ;; 680 4013 681 4013 .MainLoopInitialize 682 4013 ;; MainLoopInitialize 683 4013 684 4013 .L011 ;; controller_debounce_bit0{0} = 1 : controller_button_debounce_bit0{0} = 1 685 4013 686 4013 ad 40 01 LDA controller_debounce_bit0 687 4016 09 01 ORA #1 688 4018 8d 40 01 STA controller_debounce_bit0 689 401b ad 41 01 LDA controller_button_debounce_bit0 690 401e 09 01 ORA #1 691 4020 8d 41 01 STA controller_button_debounce_bit0 692 4023 . 693 4023 ;; 694 4023 695 4023 .MainLoop 696 4023 ;; MainLoop 697 4023 698 4023 .L012 ;; gosub ReadController 699 4023 700 4023 20 2c 41 jsr .ReadController 701 4026 702 4026 . 703 4026 ;; 704 4026 705 4026 .L013 ;; if controller_debounce_bit0{0} || controller_button_debounce_bit0{0} then goto _mainLoopSkipJoystickCheck 706 4026 707 4026 ad 40 01 LDA controller_debounce_bit0 708 4029 4a LSR 709 402a 90 03 BCC .skipL013 710 402c .condpart0 711 402c 4c 35 40 jmp .condpart1 712 402f .skipL013 713 402f ad 41 01 LDA controller_button_debounce_bit0 714 4032 4a LSR 715 4033 90 03 BCC .skip0OR 716 4035 .condpart1 717 4035 4c 23 41 jmp ._mainLoopSkipJoystickCheck 718 4038 719 4038 .skip0OR 720 4038 . 721 4038 ;; 722 4038 723 4038 .L014 ;; if controller_left_bit1{1} then controller_debounce_bit0{0} = 1 : playsfx sfx_ding 7 : BACKGRND = rand 724 4038 725 4038 ad 40 01 LDA controller_left_bit1 726 403b 29 02 AND #2 727 403d f0 28 BEQ .skipL014 728 403f .condpart2 729 403f ad 40 01 LDA controller_debounce_bit0 730 4042 09 01 ORA #1 731 4044 8d 40 01 STA controller_debounce_bit0 732 4047 a9 01 lda #1 733 4049 85 de sta sfxschedulelock 734 404b a9 ca lda #sfx_ding 737 4051 85 e1 sta sfxinstrumenthi 738 4053 a9 07 lda #7 739 4055 85 e2 sta sfxpitchoffset ; pitch modification 740 4057 a9 00 lda #0 741 4059 85 e3 sta sfxnoteindex ; not a musical note 742 405b 20 58 f2 jsr schedulesfx 743 405e a9 00 lda #0 744 4060 85 de sta sfxschedulelock 745 4062 20 a8 f3 jsr randomize 746 4065 85 20 STA BACKGRND 747 4067 .skipL014 748 4067 .L015 ;; if controller_right_bit2{2} then controller_debounce_bit0{0} = 1 : playsfx sfx_ding 9 : BACKGRND = rand 749 4067 750 4067 ad 40 01 LDA controller_right_bit2 751 406a 29 04 AND #4 752 406c f0 28 BEQ .skipL015 753 406e .condpart3 754 406e ad 40 01 LDA controller_debounce_bit0 755 4071 09 01 ORA #1 756 4073 8d 40 01 STA controller_debounce_bit0 757 4076 a9 01 lda #1 758 4078 85 de sta sfxschedulelock 759 407a a9 ca lda #sfx_ding 762 4080 85 e1 sta sfxinstrumenthi 763 4082 a9 09 lda #9 764 4084 85 e2 sta sfxpitchoffset ; pitch modification 765 4086 a9 00 lda #0 766 4088 85 e3 sta sfxnoteindex ; not a musical note 767 408a 20 58 f2 jsr schedulesfx 768 408d a9 00 lda #0 769 408f 85 de sta sfxschedulelock 770 4091 20 a8 f3 jsr randomize 771 4094 85 20 STA BACKGRND 772 4096 .skipL015 773 4096 .L016 ;; if controller_up_bit3{3} then controller_debounce_bit0{0} = 1 : playsfx sfx_ding 8 : BACKGRND = rand 774 4096 775 4096 ad 40 01 LDA controller_up_bit3 776 4099 29 08 AND #8 777 409b f0 28 BEQ .skipL016 778 409d .condpart4 779 409d ad 40 01 LDA controller_debounce_bit0 780 40a0 09 01 ORA #1 781 40a2 8d 40 01 STA controller_debounce_bit0 782 40a5 a9 01 lda #1 783 40a7 85 de sta sfxschedulelock 784 40a9 a9 ca lda #sfx_ding 787 40af 85 e1 sta sfxinstrumenthi 788 40b1 a9 08 lda #8 789 40b3 85 e2 sta sfxpitchoffset ; pitch modification 790 40b5 a9 00 lda #0 791 40b7 85 e3 sta sfxnoteindex ; not a musical note 792 40b9 20 58 f2 jsr schedulesfx 793 40bc a9 00 lda #0 794 40be 85 de sta sfxschedulelock 795 40c0 20 a8 f3 jsr randomize 796 40c3 85 20 STA BACKGRND 797 40c5 .skipL016 798 40c5 .L017 ;; if controller_down_bit4{4} then controller_debounce_bit0{0} = 1 : playsfx sfx_ding 6 : BACKGRND = rand 799 40c5 800 40c5 ad 40 01 LDA controller_down_bit4 801 40c8 29 10 AND #16 802 40ca f0 28 BEQ .skipL017 803 40cc .condpart5 804 40cc ad 40 01 LDA controller_debounce_bit0 805 40cf 09 01 ORA #1 806 40d1 8d 40 01 STA controller_debounce_bit0 807 40d4 a9 01 lda #1 808 40d6 85 de sta sfxschedulelock 809 40d8 a9 ca lda #sfx_ding 812 40de 85 e1 sta sfxinstrumenthi 813 40e0 a9 06 lda #6 814 40e2 85 e2 sta sfxpitchoffset ; pitch modification 815 40e4 a9 00 lda #0 816 40e6 85 e3 sta sfxnoteindex ; not a musical note 817 40e8 20 58 f2 jsr schedulesfx 818 40eb a9 00 lda #0 819 40ed 85 de sta sfxschedulelock 820 40ef 20 a8 f3 jsr randomize 821 40f2 85 20 STA BACKGRND 822 40f4 .skipL017 823 40f4 . 824 40f4 ;; 825 40f4 826 40f4 .L018 ;; if controller_button1_press_bit1{1} then controller_button_debounce_bit0{0} = 1 : playsfx sfx_fire 6 : BACKGRND = rand 827 40f4 828 40f4 ad 41 01 LDA controller_button1_press_bit1 829 40f7 29 02 AND #2 830 40f9 f0 28 BEQ .skipL018 831 40fb .condpart6 832 40fb ad 41 01 LDA controller_button_debounce_bit0 833 40fe 09 01 ORA #1 834 4100 8d 41 01 STA controller_button_debounce_bit0 835 4103 a9 01 lda #1 836 4105 85 de sta sfxschedulelock 837 4107 a9 03 lda #sfx_fire 840 410d 85 e1 sta sfxinstrumenthi 841 410f a9 06 lda #6 842 4111 85 e2 sta sfxpitchoffset ; pitch modification 843 4113 a9 00 lda #0 844 4115 85 e3 sta sfxnoteindex ; not a musical note 845 4117 20 58 f2 jsr schedulesfx 846 411a a9 00 lda #0 847 411c 85 de sta sfxschedulelock 848 411e 20 a8 f3 jsr randomize 849 4121 85 20 STA BACKGRND 850 4123 .skipL018 851 4123 . 852 4123 ;; 853 4123 854 4123 ._mainLoopSkipJoystickCheck 855 4123 ;; _mainLoopSkipJoystickCheck 856 4123 857 4123 .L019 ;; clearscreen 858 4123 859 4123 20 8c f0 jsr clearscreen 860 4126 . 861 4126 ;; 862 4126 863 4126 .L020 ;; drawscreen 864 4126 865 4126 20 c0 f0 jsr drawscreen 866 4129 . 867 4129 ;; 868 4129 869 4129 .L021 ;; goto MainLoop 870 4129 871 4129 4c 23 40 jmp .MainLoop 872 412c 873 412c . 874 412c ;; 875 412c 876 412c . 877 412c ;; 878 412c 879 412c .ReadController 880 412c ;; ReadController 881 412c 882 412c .L022 ;; if controllerState = %00000001 then controller_debounce_bit0{0} = 0 883 412c 884 412c ad 40 01 LDA controllerState 885 412f c9 01 CMP #%00000001 886 4131 d0 08 BNE .skipL022 887 4133 .condpart7 888 4133 ad 40 01 LDA controller_debounce_bit0 889 4136 29 fe AND #254 890 4138 8d 40 01 STA controller_debounce_bit0 891 413b .skipL022 892 413b .L023 ;; if controllerButtonState = %00000001 then controller_button_debounce_bit0{0} = 0 893 413b 894 413b ad 41 01 LDA controllerButtonState 895 413e c9 01 CMP #%00000001 896 4140 d0 08 BNE .skipL023 897 4142 .condpart8 898 4142 ad 41 01 LDA controller_button_debounce_bit0 899 4145 29 fe AND #254 900 4147 8d 41 01 STA controller_button_debounce_bit0 901 414a .skipL023 902 414a . 903 414a ;; 904 414a 905 414a .L024 ;; if !joy0any then goto _readControllerSkipJoystickDirectionCheck 906 414a 907 414a ad 80 02 lda SWCHA 908 414d 29 f0 and #$F0 909 414f 49 f0 eor #$F0 910 4151 d0 03 BNE .skipL024 911 4153 .condpart9 912 4153 4c 8e 41 jmp ._readControllerSkipJoystickDirectionCheck 913 4156 914 4156 .skipL024 915 4156 .L025 ;; if joy0left then controller_left_bit1{1} = 1 916 4156 917 4156 2c 80 02 bit SWCHA 918 4159 70 08 BVS .skipL025 919 415b .condpart10 920 415b ad 40 01 LDA controller_left_bit1 921 415e 09 02 ORA #2 922 4160 8d 40 01 STA controller_left_bit1 923 4163 .skipL025 924 4163 .L026 ;; if joy0right then controller_right_bit2{2} = 1 925 4163 926 4163 2c 80 02 bit SWCHA 927 4166 30 08 BMI .skipL026 928 4168 .condpart11 929 4168 ad 40 01 LDA controller_right_bit2 930 416b 09 04 ORA #4 931 416d 8d 40 01 STA controller_right_bit2 932 4170 .skipL026 933 4170 .L027 ;; if joy0up then controller_up_bit3{3} = 1 934 4170 935 4170 a9 10 lda #$10 936 4172 2c 80 02 bit SWCHA 937 4175 d0 08 BNE .skipL027 938 4177 .condpart12 939 4177 ad 40 01 LDA controller_up_bit3 940 417a 09 08 ORA #8 941 417c 8d 40 01 STA controller_up_bit3 942 417f .skipL027 943 417f .L028 ;; if joy0down then controller_down_bit4{4} = 1 944 417f 945 417f a9 20 lda #$20 946 4181 2c 80 02 bit SWCHA 947 4184 d0 08 BNE .skipL028 948 4186 .condpart13 949 4186 ad 40 01 LDA controller_down_bit4 950 4189 09 10 ORA #16 951 418b 8d 40 01 STA controller_down_bit4 952 418e .skipL028 953 418e . 954 418e ;; 955 418e 956 418e ._readControllerSkipJoystickDirectionCheck 957 418e ;; _readControllerSkipJoystickDirectionCheck 958 418e 959 418e .L029 ;; if joy0fire1 then controller_button1_press_bit1{1} = 1 960 418e 961 418e 2c 02 21 bit sINPT1 962 4191 10 08 BPL .skipL029 963 4193 .condpart14 964 4193 ad 41 01 LDA controller_button1_press_bit1 965 4196 09 02 ORA #2 966 4198 8d 41 01 STA controller_button1_press_bit1 967 419b .skipL029 968 419b .L030 ;; if joy0fire0 then controller_button2_press_bit4{4} = 1 969 419b 970 419b 2c 02 21 bit sINPT1 971 419e 50 08 BVC .skipL030 972 41a0 .condpart15 973 41a0 ad 41 01 LDA controller_button2_press_bit4 974 41a3 09 10 ORA #16 975 41a5 8d 41 01 STA controller_button2_press_bit4 976 41a8 .skipL030 977 41a8 . 978 41a8 ;; 979 41a8 980 41a8 .L031 ;; if controllerState = %00000001 then controller_debounce_bit0{0} = 0 981 41a8 982 41a8 ad 40 01 LDA controllerState 983 41ab c9 01 CMP #%00000001 984 41ad d0 08 BNE .skipL031 985 41af .condpart16 986 41af ad 40 01 LDA controller_debounce_bit0 987 41b2 29 fe AND #254 988 41b4 8d 40 01 STA controller_debounce_bit0 989 41b7 .skipL031 990 41b7 .L032 ;; if controllerButtonState = %00000001 then controller_button_debounce_bit0{0} = 0 991 41b7 992 41b7 ad 41 01 LDA controllerButtonState 993 41ba c9 01 CMP #%00000001 994 41bc d0 08 BNE .skipL032 995 41be .condpart17 996 41be ad 41 01 LDA controller_button_debounce_bit0 997 41c1 29 fe AND #254 998 41c3 8d 41 01 STA controller_button_debounce_bit0 999 41c6 .skipL032 1000 41c6 . 1001 41c6 ;; 1002 41c6 1003 41c6 .L033 ;; return 1004 41c6 1005 41c6 60 RTS 1006 41c7 . 1007 41c7 ;; 1008 41c7 1009 41c7 .L034 ;; data sfx_ding 1010 41c7 1011 41c7 4c 00 42 JMP .skipL034 1012 41ca sfx_ding 1013 41ca 10 00 01 .byte.b 16, 0, 1 1014 41cd 1015 41cd 01 04 08 .byte.b $01,$04,$08 1016 41d0 1017 41d0 01 04 04 .byte.b $01,$04,$04 1018 41d3 1019 41d3 01 04 07 .byte.b $01,$04,$07 1020 41d6 1021 41d6 01 04 03 .byte.b $01,$04,$03 1022 41d9 1023 41d9 01 04 06 .byte.b $01,$04,$06 1024 41dc 1025 41dc 01 04 02 .byte.b $01,$04,$02 1026 41df 1027 41df 01 04 05 .byte.b $01,$04,$05 1028 41e2 1029 41e2 01 04 01 .byte.b $01,$04,$01 1030 41e5 1031 41e5 01 04 04 .byte.b $01,$04,$04 1032 41e8 1033 41e8 01 04 00 .byte.b $01,$04,$00 1034 41eb 1035 41eb 01 04 03 .byte.b $01,$04,$03 1036 41ee 1037 41ee 01 04 00 .byte.b $01,$04,$00 1038 41f1 1039 41f1 01 04 02 .byte.b $01,$04,$02 1040 41f4 1041 41f4 01 04 00 .byte.b $01,$04,$00 1042 41f7 1043 41f7 01 04 01 .byte.b $01,$04,$01 1044 41fa 1045 41fa 01 04 00 .byte.b $01,$04,$00 1046 41fd 1047 41fd 00 00 00 .byte.b $00,$00,$00 1048 4200 1049 4200 .skipL034 1050 4200 00 ca sfx_ding_lo = #sfx_ding 1052 4200 . 1053 4200 ;; 1054 4200 1055 4200 .L035 ;; data sfx_fire 1056 4200 1057 4200 4c 2d 42 JMP .skipL035 1058 4203 sfx_fire 1059 4203 10 01 01 .byte.b 16, 1, 1 1060 4206 1061 4206 01 0c 08 .byte.b $01,$0c,$08 1062 4209 1063 4209 07 0c 08 .byte.b $07,$0c,$08 1064 420c 1065 420c 09 0c 08 .byte.b $09,$0c,$08 1066 420f 1067 420f 0b 0c 08 .byte.b $0b,$0c,$08 1068 4212 1069 4212 01 0c 04 .byte.b $01,$0c,$04 1070 4215 1071 4215 07 0c 04 .byte.b $07,$0c,$04 1072 4218 1073 4218 09 0c 04 .byte.b $09,$0c,$04 1074 421b 1075 421b 0b 0c 04 .byte.b $0b,$0c,$04 1076 421e 1077 421e 01 0c 02 .byte.b $01,$0c,$02 1078 4221 1079 4221 07 0c 02 .byte.b $07,$0c,$02 1080 4224 1081 4224 09 0c 02 .byte.b $09,$0c,$02 1082 4227 1083 4227 0b 0c 02 .byte.b $0b,$0c,$02 1084 422a 1085 422a 00 00 00 .byte.b $00,$00,$00 1086 422d 1087 422d .skipL035 1088 422d 00 03 sfx_fire_lo = #sfx_fire 1090 422d DMAHOLEEND0 SET . 1091 422d gameend 1092 422d DMAHOLEEND0 SET . 44499 bytes of ROM space left in the main area. 1093 422d echo " ",[($F000 - gameend)]d , "bytes of ROM space left in the main area." 1094 422d - if ($F000 - gameend) < 0 1095 422d -SPACEOVERFLOW SET (SPACEOVERFLOW+1) 1096 422d endif 1097 422d - if SPACEOVERFLOW > 0 1098 422d - echo "" 1099 422d - echo "######## ERROR: space overflow detected in",[SPACEOVERFLOW]d,"areas." 1100 422d - echo "######## look above for areas with negative ROM space left." 1101 422d - echo "######## Aborting assembly." 1102 422d - ERR 1103 422d endif 1104 422d 1105 422d 1106 422d ; Provided under the CC0 license. See the included LICENSE.txt for details. 1107 422d 1108 422d ifnconst bankswitchmode 1109 422d if ( * < $f000 ) 1110 f000 ORG $F000 1111 f000 endif 1112 f000 - else 1113 f000 - ifconst ROM128K 1114 f000 - if ( * < $f000 ) 1115 f000 - ORG $27000 1116 f000 - RORG $F000 1117 f000 - endif 1118 f000 - endif 1119 f000 - ifconst ROM144K 1120 f000 - if ( * < $f000 ) 1121 f000 - ORG $27000 1122 f000 - RORG $F000 1123 f000 - endif 1124 f000 - endif 1125 f000 - ifconst ROM256K 1126 f000 - if ( * < $f000 ) 1127 f000 - ORG $47000 1128 f000 - RORG $F000 1129 f000 - endif 1130 f000 - endif 1131 f000 - ifconst ROM272K 1132 f000 - if ( * < $f000 ) 1133 f000 - ORG $47000 1134 f000 - RORG $F000 1135 f000 - endif 1136 f000 - endif 1137 f000 - ifconst ROM512K 1138 f000 - if ( * < $f000 ) 1139 f000 - ORG $87000 1140 f000 - RORG $F000 1141 f000 - endif 1142 f000 - endif 1143 f000 - ifconst ROM528K 1144 f000 - if ( * < $f000 ) 1145 f000 - ORG $87000 1146 f000 - RORG $F000 1147 f000 - endif 1148 f000 - endif 1149 f000 endif 1150 f000 1151 f000 ; all of these "modules" have conditional clauses in them, so even though 1152 f000 ; they're always included here, they don't take up rom unless the user 1153 f000 ; explicitly enables support for the feature. 1154 f000 1155 f000 ifnconst included.7800vox.asm ------- FILE 7800vox.asm LEVEL 2 PASS 3 0 f000 include 7800vox.asm 1 f000 ; Provided under the CC0 license. See the included LICENSE.txt for details. 2 f000 3 f000 ; AtariVox 7800basic wrapper 4 f000 5 f000 ; to be called with 6 f000 ; A=# of bytes 7 f000 ; 8 f000 9 f000 - ifconst HSSUPPORT 10 f000 - 11 f000 -AVoxReadBytes 12 f000 - sta temp8 13 f000 - jsr i2c_startwrite 14 f000 - bcs eeprom_error 15 f000 - 16 f000 - lda HSVoxHi 17 f000 - jsr i2c_txbyte 18 f000 - lda HSVoxLo 19 f000 - jsr i2c_txbyte 20 f000 - jsr i2c_stopwrite 21 f000 - 22 f000 - jsr i2c_startread 23 f000 - 24 f000 - ldx #0 25 f000 -AVoxReadBytesLoop 26 f000 - jsr i2c_rxbyte 27 f000 - sta eeprombuffer,x 28 f000 - inx 29 f000 - cpx temp8 30 f000 - bne AVoxReadBytesLoop 31 f000 - jsr i2c_stopread 32 f000 - lda #0 33 f000 - rts 34 f000 - 35 f000 - ; to be called with 36 f000 - ; A=# of bytes 37 f000 - ; 38 f000 - 39 f000 -AVoxWriteBytes 40 f000 - sta temp8 41 f000 - jsr i2c_startwrite 42 f000 - bcs eeprom_error 43 f000 - 44 f000 - lda HSVoxHi 45 f000 - jsr i2c_txbyte 46 f000 - lda HSVoxLo 47 f000 - jsr i2c_txbyte 48 f000 - 49 f000 - ldx #$00 50 f000 -AVoxWriteBytesLoop 51 f000 - lda eeprombuffer,x 52 f000 - jsr i2c_txbyte 53 f000 - inx 54 f000 - cpx temp8 55 f000 - bne AVoxWriteBytesLoop 56 f000 - jsr i2c_stopwrite 57 f000 - 58 f000 - lda #0 59 f000 - rts 60 f000 - 61 f000 -eeprom_error 62 f000 - lda #$ff 63 f000 - rts 64 f000 - 65 f000 -AVoxDetect 66 f000 - 67 f000 - jsr i2c_startwrite 68 f000 - bcs eeprom_error 69 f000 - lda #$30 70 f000 - jsr i2c_txbyte 71 f000 - lda #$00 72 f000 - jsr i2c_txbyte 73 f000 - jsr i2c_stopwrite 74 f000 - rts 75 f000 - 76 f000 - include "i2c7800.inc" 77 f000 - I2C_SUBS temp9 78 f000 - 79 f000 endif 80 f000 ------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm 1157 f000 endif 1158 f000 ifnconst included.pokeysound.asm ------- FILE pokeysound.asm LEVEL 2 PASS 3 0 f000 include pokeysound.asm 1 f000 ; Provided under the CC0 license. See the included LICENSE.txt for details. 2 f000 3 f000 4 f000 - ifconst pokeysupport 5 f000 - 6 f000 -pokeysoundmodulestart 7 f000 - 8 f000 -mutepokey 9 f000 - lda #0 10 f000 - ldy #7 11 f000 -mutepokeyloop 12 f000 - sta pokey1pointlo,y 13 f000 - sta (pokeybaselo),y 14 f000 - dey 15 f000 - bpl mutepokeyloop 16 f000 - rts 17 f000 - 18 f000 -checkpokeyplaying 19 f000 - ldx #6 20 f000 -checkpokeyplayingloop 21 f000 - lda pokey1pointlo,x 22 f000 - ora pokey1pointhi,x 23 f000 - beq pokeychannelinactive 24 f000 - jsr playpokeysfxA ; x=channel*2 25 f000 -pokeychannelinactive 26 f000 - dex 27 f000 - dex 28 f000 - bpl checkpokeyplayingloop 29 f000 - rts 30 f000 - 31 f000 -playpokeysfxA 32 f000 - txa 33 f000 - tay 34 f000 - lda pokey1tick,x 35 f000 - beq playpokeysfxAcont 36 f000 - sec 37 f000 - sbc #1 38 f000 - sta pokey1tick,x ; sound resolution is >1 frame, and we're mid-tock... 39 f000 - rts 40 f000 - 41 f000 -playpokeysfxAcont 42 f000 - lda pokey1frames,x ; set the frame countdown for this sound chunk 43 f000 - sta pokey1tick,x 44 f000 - 45 f000 - lda pokey1priority,x ; decrease the sound's priority if its non-zero 46 f000 - beq playpokeysfxAcont2 47 f000 - sec 48 f000 - sbc #1 49 f000 - sta pokey1priority,x 50 f000 -playpokeysfxAcont2 51 f000 - 52 f000 - ; *** FREQUENCY 53 f000 - lda (pokey1pointlo,x) 54 f000 - sta temp1 55 f000 - clc 56 f000 - adc pokey1offset,x ; take into account any pitch modification 57 f000 - sta (pokeybaselo),y ; PAUDF0,0 58 f000 - 59 f000 - ;advance the data pointer +1 60 f000 - inc pokey1pointlo,x 61 f000 - bne skippokeyhiinc1 62 f000 - inc pokey1pointhi,x 63 f000 -skippokeyhiinc1 64 f000 - 65 f000 - ; *** WAVE 66 f000 - lda (pokey1pointlo,x) 67 f000 - asl 68 f000 - asl 69 f000 - asl 70 f000 - asl ; x16 71 f000 - 72 f000 - ;advance the data pointer +1 73 f000 - inc pokey1pointlo,x 74 f000 - bne skippokeyhiinc2 75 f000 - inc pokey1pointhi,x 76 f000 -skippokeyhiinc2 77 f000 - 78 f000 - ora (pokey1pointlo,x) 79 f000 - iny 80 f000 - sta (pokeybaselo),y 81 f000 - 82 f000 - ora temp1 ; check if F|C|V=0 83 f000 - beq zeropokeypoint ; if so, we're at the end of the sound. 84 f000 - 85 f000 - ; advance the pointer +1, on to the next sound chunk 86 f000 - inc pokey1pointlo,x 87 f000 - bne skippokeyhiinc3 88 f000 - inc pokey1pointhi,x 89 f000 -skippokeyhiinc3 90 f000 - rts 91 f000 - 92 f000 -zeropokeypoint 93 f000 - sta pokey1pointlo,x 94 f000 - sta pokey1pointhi,x 95 f000 - sta pokey1priority,x 96 f000 - rts 97 f000 - 98 f000 -schedulepokeysfx 99 f000 - ldx #6 100 f000 -schedulepokeysfxloop 101 f000 - lda pokey1pointlo,x 102 f000 - ora pokey1pointhi,x 103 f000 - bne schedulespokeysearch 104 f000 - jmp schedulepokeyX ; we found an unused channel, so use it... 105 f000 -schedulespokeysearch 106 f000 - dex 107 f000 - dex 108 f000 - bpl schedulepokeysfxloop 109 f000 - 110 f000 - ; if we're here, all 4 channels are presently playing a sound... 111 f000 - ldy #1 112 f000 - lda (temp1),y ; peek at the priority of this sfx... 113 f000 - bne schedulepokeysfxcont1 114 f000 - rts ; ...and skip it if it's 0 priority 115 f000 -schedulepokeysfxcont1 116 f000 - 117 f000 - ; figure out which current sound has the lowest priority... 118 f000 - lda #0 119 f000 - sta temp8 120 f000 - lda pokey1priority 121 f000 - sta temp9 122 f000 - ldx #6 123 f000 -findlowprioritypokeyloop 124 f000 - lda pokey1priority,x 125 f000 - cmp temp9 126 f000 - bcs findlowprioritypokeyloopcontinue 127 f000 - sta temp9 128 f000 - stx temp8 129 f000 -findlowprioritypokeyloopcontinue 130 f000 - dex 131 f000 - dex 132 f000 - bne findlowprioritypokeyloop 133 f000 - ldx temp8 ; the low priority channel we'll interrupt 134 f000 - 135 f000 -schedulepokeyX 136 f000 - ;called with X=2*pokey channel to play on... 137 f000 - ldy #1 ; get priority and sound-resolution (in frames) 138 f000 - lda (temp1),y 139 f000 - sta pokey1priority,x 140 f000 - iny 141 f000 - lda (temp1),y 142 f000 - sta pokey1frames,x 143 f000 - 144 f000 - lda temp1 145 f000 - clc 146 f000 - adc #3 147 f000 - sta pokey1pointlo,x 148 f000 - lda temp2 149 f000 - adc #0 150 f000 - sta pokey1pointhi,x 151 f000 - lda temp3 152 f000 - sta pokey1offset,x 153 f000 - lda #0 154 f000 - sta pokey1tick,x 155 f000 - rts 156 f000 - 157 f000 - ; pokey detection routine. we check for pokey in the XBOARD/XM location, 158 f000 - ; and the standard $4000 location. 159 f000 - ; if pokey the pokey is present, this routine will reset it. 160 f000 - 161 f000 -detectpokeylocation 162 f000 - ;XBoard/XM... 163 f000 - ldx #2 164 f000 -detectpokeyloop 165 f000 - lda XCTRL1s 166 f000 - ora #%00010100 167 f000 - and POKEYXMMASK,x 168 f000 - sta XCTRL1s 169 f000 - sta XCTRL1 170 f000 - 171 f000 - lda POKEYCHECKLO,x 172 f000 - sta pokeybaselo 173 f000 - lda POKEYCHECKHI,x 174 f000 - sta pokeybasehi 175 f000 - jsr checkforpokey 176 f000 - lda pokeydetected 177 f000 - beq foundpokeychip 178 f000 - dex 179 f000 - bpl detectpokeyloop 180 f000 -foundpokeychip 181 f000 - eor #$ff ; invert state for 7800basic if...then test 182 f000 - sta pokeydetected 183 f000 - rts 184 f000 - 185 f000 -POKEYXMMASK 186 f000 - ; XM POKEY on XM POKEY off XM POKEY off 187 f000 - .byte %11111111, %11101111, %11101111 188 f000 - 189 f000 -POKEYCHECKLO 190 f000 - .byte <$0450, <$0450, <$4000 191 f000 -POKEYCHECKHI 192 f000 - .byte >$0450, >$0450, >$4000 193 f000 - 194 f000 -checkforpokey 195 f000 - ldy #$0f 196 f000 - lda #$00 197 f000 - sta pokeydetected ; start off by assuming pokey will be detected 198 f000 -resetpokeyregistersloop 199 f000 - sta (pokeybase),y 200 f000 - dey 201 f000 - bpl resetpokeyregistersloop 202 f000 - 203 f000 - ldy #PAUDCTL 204 f000 - sta (pokeybase),y 205 f000 - ldy #PSKCTL 206 f000 - sta (pokeybase),y 207 f000 - 208 f000 - ; let the dust settle... 209 f000 - nop 210 f000 - nop 211 f000 - nop 212 f000 - 213 f000 - lda #4 214 f000 - sta temp9 215 f000 -pokeycheckloop1 216 f000 - ; we're in reset, so the RANDOM register should read $ff... 217 f000 - ldy #PRANDOM 218 f000 - lda (pokeybase),y 219 f000 - cmp #$ff 220 f000 - bne nopokeydetected 221 f000 - dec temp9 222 f000 - bne pokeycheckloop1 223 f000 - 224 f000 - ; take pokey out of reset... 225 f000 - ldy #PSKCTL 226 f000 - lda #3 227 f000 - sta (pokeybase),y 228 f000 - ldy #PAUDCTL 229 f000 - lda #0 230 f000 - sta (pokeybase),y 231 f000 - 232 f000 - ; let the dust settle again... 233 f000 - nop 234 f000 - nop 235 f000 - nop 236 f000 - 237 f000 - lda #4 238 f000 - sta temp9 239 f000 -pokeycheckloop2 240 f000 - ; we're out of reset, so RANDOM should read non-$ff... 241 f000 - ldy #PRANDOM 242 f000 - lda (pokeybase),y 243 f000 - cmp #$ff 244 f000 - beq skippokeycheckreturn 245 f000 - rts 246 f000 -skippokeycheckreturn 247 f000 - dec temp9 248 f000 - bne pokeycheckloop2 249 f000 -nopokeydetected 250 f000 - dec pokeydetected ; pokeydetected=#$ff 251 f000 - rts 252 f000 - 253 f000 -pokeysoundmoduleend 254 f000 - 255 f000 - echo " pokeysound assembly: ",[(pokeysoundmoduleend-pokeysoundmodulestart)]d," bytes" 256 f000 - 257 f000 endif ------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm 1160 f000 endif 1161 f000 ifnconst included.tracker.asm ------- FILE tracker.asm LEVEL 2 PASS 3 0 f000 include tracker.asm 1 f000 ; Provided under the CC0 license. See the included LICENSE.txt for details. 2 f000 3 f000 4 f000 - ifconst MUSICTRACKER 5 f000 - ; ** songtempo lists how many 256ths of a frame a 16th note lasts 6 f000 - ; ** the player operates on a 16th note grid. 7 f000 - 8 f000 -servicesongover 9 f000 - rts 10 f000 -servicesong 11 f000 - lda songtempo 12 f000 - beq servicesongover ; ** if song is off/paused then return 13 f000 -servicesongcontinue 14 f000 - lda sfxschedulelock 15 f000 - sta sfxschedulemissed 16 f000 - bne servicesongover 17 f000 - lda songtempo 18 f000 - clc 19 f000 - adc songtick ; add songtempo to songtick until it rolls over 20 f000 - sta songtick ; this is how we break away from 50/60Hz timing. 21 f000 - bcc servicesongover 22 f000 - ; ** if we're here a new 16th note has passed 23 f000 - ; ** check if a new note is due on any of the 4 channels 24 f000 -servicesongredo 25 f000 - ldx #3 26 f000 -checkchannelloop 27 f000 - dec songchannel1busywait,x 28 f000 - bpl carryoncheckingchannel 29 f000 - txa 30 f000 - pha ; save X for the loop 31 f000 - jsr processsongdata 32 f000 - pla ; restore X for the loop 33 f000 - tax 34 f000 -carryoncheckingchannel 35 f000 - dex 36 f000 - bpl checkchannelloop 37 f000 - lda inactivechannelcount 38 f000 - cmp #15 39 f000 - bne skipstopsong 40 f000 - lda songloops 41 f000 - bne doasongloop 42 f000 - ;lda #0 43 f000 - sta songtempo ; all channels are done. stop the song 44 f000 - rts 45 f000 -doasongloop 46 f000 - bmi skipsongloopadjust 47 f000 - dec songloops 48 f000 -skipsongloopadjust 49 f000 - jsr setsongchannels 50 f000 - jmp servicesongredo 51 f000 -skipstopsong 52 f000 - rts 53 f000 - 54 f000 -processsongdata 55 f000 - ; channel needs processing 56 f000 - ; X=channel # 57 f000 - 58 f000 - txa 59 f000 - clc 60 f000 - adc songchannel1stackdepth,x ; stack depth value will be 0, 4, or 8 61 f000 - tay 62 f000 - 63 f000 - 64 f000 - ; ** indirect x is cumbersome with mult-byte commands. 65 f000 - ; ** setup a pointer to the song data for indirect y addressing. 66 f000 - lda songchannel1layer1lo,y 67 f000 - sta songdatalo 68 f000 - lda songchannel1layer1hi,y 69 f000 - sta songdatahi 70 f000 - ora songdatalo 71 f000 - bne channelhasdata 72 f000 - ;channel data is pointing at $0000 73 f000 - lda #$7F 74 f000 - sta songchannel1busywait,x ; skip a bunch of notes 75 f000 -setchannelcountbits 76 f000 - lda channel2bits,x 77 f000 - ora inactivechannelcount 78 f000 - sta inactivechannelcount 79 f000 - rts 80 f000 -channelhasdata 81 f000 - 82 f000 - sty songstackindex 83 f000 - ldy #0 84 f000 - lda (songdatalo),y ; ** load in the next byte of song data, so we can decode it 85 f000 - cmp #$ff 86 f000 - bne carryoncheckingdatatype ; ** $ff=pattern end marker 87 f000 - jmp handlechannelEOD 88 f000 - 89 f000 -carryoncheckingdatatype 90 f000 - and #$F0 91 f000 - cmp #$C0 92 f000 - beq handlechannelrest ; 0000XXXX=rest 93 f000 - cmp #$F0 94 f000 - beq handlemultibytecommand 95 f000 - cmp #$D0 96 f000 - beq handlesemiup 97 f000 - cmp #$E0 98 f000 - beq handlesemidown 99 f000 -handlenotedata 100 f000 - ; ** TODO: note playing is a terrible choice for fall-through 101 f000 - 102 f000 - ; ** its simple note data, prepare arguments for schedulesfx 103 f000 - 104 f000 - ; ** set the note length 105 f000 - lda (songdatalo),y 106 f000 - and #$0F 107 f000 - sta songchannel1busywait,x 108 f000 - 109 f000 - ; ** load the instrument 110 f000 - lda songchannel1instrumentlo,x 111 f000 - sta sfxinstrumentlo 112 f000 - lda songchannel1instrumenthi,x 113 f000 - sta sfxinstrumenthi 114 f000 - 115 f000 - ; ** get the note, and transpose 116 f000 - lda (songdatalo),y 117 f000 - lsr 118 f000 - lsr 119 f000 - lsr 120 f000 - lsr 121 f000 - clc 122 f000 - adc songchannel1transpose,x ; ** add it to the transpose index 123 f000 - ; ** its up the respective SFX scheduler to handle and save the note data 124 f000 - sta sfxnoteindex 125 f000 - 126 f000 - lda #0 127 f000 - sta sfxpitchoffset 128 f000 - 129 f000 - jsr schedulesfx 130 f000 - 131 f000 - jmp advancethesongpointer1byte ; advance to the next data byte and exit 132 f000 - 133 f000 -handlechannelrest 134 f000 - ; ** set the note length 135 f000 - lda (songdatalo),y 136 f000 - and #$0F 137 f000 - sta songchannel1busywait,x 138 f000 - jmp advancethesongpointer1byte ; advance to the next data byte and exit 139 f000 - 140 f000 -handlesemiup 141 f000 - lda (songdatalo),y ; ** reload the song data, so we can get at the lower nibble 142 f000 - and #$0f ; ** since we need to mask the nibble of the subtracted value, 143 f000 - clc 144 f000 -handlesemidownentry 145 f000 - adc songchannel1transpose,x ; ** add it to the transpose index 146 f000 - sta songchannel1transpose,x 147 f000 - jsr advancethesongpointer1byte 148 f000 - jmp processsongdata ; semi doesn't have note length, so process the next data byte... 149 f000 - 150 f000 -handlesemidown 151 f000 - lda (songdatalo),y ; ** reload the song data, so we can get at the lower nibble 152 f000 - and #$0f ; ** since we need to mask the nibble of the subtracted value, 153 f000 - eor #$ff ; ** its easier if we negate it, and then add it instead. 154 f000 - sec 155 f000 - jmp handlesemidownentry 156 f000 - 157 f000 -handlemultibytecommand 158 f000 - lda (songdatalo),y ; ** reload the song data, so we can get at the lower nibble 159 f000 - and #$0f ; ** since we need to mask the nibble of the subtracted value, 160 f000 - cmp #$08 ; ** load new instrument? 161 f000 - bne nothandleinstrumentchange 162 f000 -handleinstrumentchange 163 f000 - iny 164 f000 - lda (songdatalo),y 165 f000 - sta songchannel1instrumentlo,x 166 f000 - iny 167 f000 - lda (songdatalo),y 168 f000 - sta songchannel1instrumenthi,x 169 f000 - lda #3 170 f000 - jsr advancethesongpointerNbytes ; advance 3 bytes 171 f000 - jmp processsongdata 172 f000 - 173 f000 -nothandleinstrumentchange 174 f000 - cmp #$09 ; ** absolute tempo change? 175 f000 - bne nothandletempochange 176 f000 - lda #0 177 f000 - sta songtempo 178 f000 -handlerelativetempochange 179 f000 - iny 180 f000 - lda (songdatalo),y 181 f000 - clc 182 f000 - adc songtempo 183 f000 - sta songtempo 184 f000 - lda #2 185 f000 - jsr advancethesongpointerNbytes ; advance 2 bytes 186 f000 - jmp processsongdata 187 f000 - 188 f000 -nothandletempochange 189 f000 - cmp #$0A ; ** relative tempo change?: 190 f000 - beq handlerelativetempochange 191 f000 - cmp #$0B ; ** octave/semi change? 192 f000 - beq handleoctavesemichange 193 f000 -handlepatterndata 194 f000 - ; ** if we're here its a pattern/loop "subroutine" 195 f000 - ; ** move the channel's "stack" pointer and populate the new stack level 196 f000 - 197 f000 - lda #4 198 f000 - clc 199 f000 - adc songchannel1stackdepth,x 200 f000 - sta songchannel1stackdepth,x ; stack depth value will be 0, 4, or 8 201 f000 - 202 f000 - stx inttemp6 ; about to invalidate x. save it. 203 f000 - lda songstackindex 204 f000 - adc #4 205 f000 - tax 206 f000 - 207 f000 - lda (songdatalo),y 208 f000 - and #$7 209 f000 - sta songchannel1layer1loops,x 210 f000 - iny 211 f000 - lda (songdatalo),y 212 f000 - sta songchannel1layer1lo,x 213 f000 - iny 214 f000 - lda (songdatalo),y 215 f000 - sta songchannel1layer1hi,x 216 f000 - 217 f000 - ldx inttemp6 ; restore x with the channel # 218 f000 - 219 f000 - ; ** advance will operate on the old stack level, since we didn't store the updated songstackindex... 220 f000 - lda #3 221 f000 - jsr advancethesongpointerNbytes ; advance 3 bytes 222 f000 - 223 f000 - ; ** ...but the new stack level will be correctly picked up when we process the next byte. 224 f000 - jmp processsongdata 225 f000 - 226 f000 -handlechannelEOD 227 f000 - ; ** check if there are loops remaining on the pattern 228 f000 - stx inttemp6 229 f000 - ldx songstackindex 230 f000 - dec songchannel1layer1loops,x 231 f000 - bmi handlechannelEODnoloop 232 f000 - ; ** loops are remaining. set the pattern pointer to the pattern start, which is contained after the EOD 233 f000 - iny 234 f000 - lda (songdatalo),y 235 f000 - sta songchannel1layer1lo,x 236 f000 - iny 237 f000 - lda (songdatalo),y 238 f000 - sta songchannel1layer1hi,x 239 f000 - ldx inttemp6 240 f000 - jmp processsongdata ; EOD handling doesn't have note length, so process the next data byte... 241 f000 - 242 f000 -handlechannelEODnoloop 243 f000 - ; this pattern/loop is done playing. "pop" the stack 244 f000 - ldx inttemp6 245 f000 - lda songchannel1stackdepth,x 246 f000 - beq handlerootchannelEOD 247 f000 - sec 248 f000 - sbc #4 249 f000 - sta songchannel1stackdepth,x 250 f000 - jmp processsongdata ; EOD handling doesn't have note length, so process the next data byte... 251 f000 - 252 f000 -handlerootchannelEOD 253 f000 - ; this channel is done. point it to $ff data so we no longer process this channel. 254 f000 - lda #0 255 f000 - sta songchannel1layer1lo,x 256 f000 - sta songchannel1layer1hi,x 257 f000 - sta songchannel1busywait,x 258 f000 - jmp setchannelcountbits 259 f000 - rts 260 f000 - 261 f000 -nothandlepatternchange 262 f000 -handleoctavesemichange 263 f000 - iny 264 f000 - lda (songdatalo),y 265 f000 - sta songchannel1transpose,x 266 f000 - lda #2 267 f000 - jsr advancethesongpointerNbytes ; advance 2 bytes 268 f000 - jmp processsongdata 269 f000 - 270 f000 -advancethesongpointer1byte 271 f000 - txa 272 f000 - ldx songstackindex 273 f000 - inc songchannel1layer1lo,x 274 f000 - bne skiphiadvancethesongpointer1byte 275 f000 - inc songchannel1layer1hi,x 276 f000 -skiphiadvancethesongpointer1byte 277 f000 - tax 278 f000 - rts 279 f000 - 280 f000 -advancethesongpointerNbytes 281 f000 - ; entered with A=# of byte to advance 282 f000 - stx inttemp6 283 f000 - ldx songstackindex 284 f000 - clc 285 f000 - adc songchannel1layer1lo,x 286 f000 - sta songchannel1layer1lo,x 287 f000 - lda #0 288 f000 - adc songchannel1layer1hi,x 289 f000 - sta songchannel1layer1hi,x 290 f000 - ldx inttemp6 291 f000 - rts 292 f000 - 293 f000 -clearsongmemory 294 f000 - lda #0 295 f000 - ldx #(songchannel4instrumenthi-songchannel1layer1lo) 296 f000 -clearsongmemoryloop1 297 f000 - sta songchannel1layer1lo,x 298 f000 - dex 299 f000 - bpl clearsongmemoryloop1 300 f000 - 301 f000 - ldx #(songchannel4stackdepth-songchannel1layer1loops) 302 f000 -clearsongmemoryloop2 303 f000 - sta songchannel1layer1loops,x 304 f000 - dex 305 f000 - bpl clearsongmemoryloop2 306 f000 - 307 f000 - lda #$ff 308 f000 - ldx #3 309 f000 -clearsongmemoryloop3 310 f000 - sta songchannel1busywait,x 311 f000 - dex 312 f000 - bpl clearsongmemoryloop3 313 f000 - rts 314 f000 - 315 f000 -setsongchannels 316 f000 - jsr clearsongmemory 317 f000 - ldy #7 318 f000 - ldx #3 319 f000 -setsongchannelsloop 320 f000 - lda (songpointerlo),y 321 f000 - sta songchannel1layer1hi,x 322 f000 - dey 323 f000 - lda (songpointerlo),y 324 f000 - sta songchannel1layer1lo,x 325 f000 - dex 326 f000 - dey 327 f000 - bpl setsongchannelsloop 328 f000 - rts 329 f000 - 330 f000 -channel2bits 331 f000 - .byte 1,2,4,8 332 f000 - 333 f000 -tiatrackeroctavenotes 334 f000 - ifconst BUZZBASS 335 f000 -LOWC = 15 336 f000 - else 337 f000 -LOWC = 14 338 f000 - endif 339 f000 - ; ****** ELECTRONIC (0 to 11) 340 f000 - .byte LOWC,20 ; c0 16.1Hz 341 f000 - .byte LOWC,18 ; c#0 342 f000 - .byte LOWC,17 ; d0 343 f000 - .byte LOWC,16 ; d#0 344 f000 - .byte LOWC,15 ; e0 345 f000 - .byte LOWC,14 ; f0 (very off) 346 f000 - .byte LOWC,14 ; f#0 347 f000 - .byte LOWC,13 ; g0 348 f000 - .byte LOWC,12 ; g#0 349 f000 - .byte LOWC,11 ; a0 350 f000 - .byte LOWC,11 ; a#0 (very off) 351 f000 - .byte LOWC,10 ; b0 30.7Hz 352 f000 - 353 f000 - ; ****** SLIGHTLY BUZZY (12 to 23) 354 f000 - .byte 6,30 ; c1 32.7Hz 355 f000 - .byte 6,28 ; c#1 356 f000 - .byte 6,27 ; d1 357 f000 - .byte 6,25 ; d#1 358 f000 - .byte 6,24 ; e1 359 f000 - .byte 6,22 ; f1 360 f000 - .byte 6,21 ; f#1 361 f000 - .byte 6,20 ; g1 362 f000 - .byte 6,18 ; g#1 363 f000 - .byte 6,17 ; a1 364 f000 - .byte 6,16 ; a#1 365 f000 - .byte 6,15 ; b1 63.4Hz 366 f000 - 367 f000 - ; ****** BUZZY (24 to 39) 368 f000 - .byte 1,31 ; c2 65.5 369 f000 - .byte 1,30 ; c#2 67.6 370 f000 - .byte 1,27 ; d2 72.3 371 f000 - .byte 1,26 ; d#2 77.6 372 f000 - .byte 1,24 ; e2 373 f000 - .byte 1,23 ; f2 374 f000 - .byte 1,22 ; f#2 375 f000 - .byte 1,20 ; g2 376 f000 - .byte 1,19 ; g#2 377 f000 - .byte 1,18 ; a2 378 f000 - .byte 1,17 ; a#2 379 f000 - .byte 1,16 ; b2 380 f000 - .byte 1,15 ; c3 126.8Hz 381 f000 - .byte 1,14 ; c#3 382 f000 - .byte 1,13 ; d3 149.7Hz 383 f000 - .byte 1,12 ; d#3 161.2Hz (very off) 384 f000 - ; ****** PURE (40 to 71) - best key is A3 Major 385 f000 - .byte 12,31 ; e3 163.8Hz 386 f000 - .byte 12,29 ; f3 387 f000 - .byte 12,28 ; f#3 388 f000 - .byte 12,26 ; g3 389 f000 - .byte 12,24 ; g#3 390 f000 - .byte 12,23 ; a3 songs in key of A benefit from Perceptual Tuning 391 f000 - .byte 12,22 ; a#3 392 f000 - .byte 12,20 ; b3 393 f000 - .byte 12,19 ; c4 (middle C) 394 f000 - .byte 12,18 ; c#4 395 f000 - .byte 12,17 ; d4 396 f000 - .byte 12,16 ; d#4 397 f000 - .byte 12,15 ; e4 398 f000 - .byte 12,14 ; f4 399 f000 - .byte 12,13 ; f#4 400 f000 - .byte 12,12 ; g4 (very off) 401 f000 - .byte 12,12 ; g#4 402 f000 - .byte 12,11 ; a4 403 f000 - .byte 12,10 ; a#4 404 f000 - .byte 4,31 ; b4 405 f000 - .byte 4,29 ; c5 406 f000 - .byte 4,28 ; c#5 407 f000 - .byte 4,26 ; d5 408 f000 - .byte 4,24 ; d#5 409 f000 - .byte 4,23 ; e5 410 f000 - .byte 4,22 ; f5 411 f000 - .byte 4,20 ; f#5 412 f000 - .byte 4,19 ; g5 413 f000 - .byte 4,18 ; g#5 414 f000 - .byte 4,17 ; a5 415 f000 - .byte 4,16 ; a#5 416 f000 - .byte 4,15 ; b5 417 f000 - 418 f000 - ; ****** TUNED WIND (72 to 83) 419 f000 - .byte 8,30 ; c 420 f000 - .byte 8,28 ; c# 421 f000 - .byte 8,27 ; d 422 f000 - .byte 8,25 ; d# 423 f000 - .byte 8,24 ; e 424 f000 - .byte 8,22 ; f 425 f000 - .byte 8,21 ; f# 426 f000 - .byte 8,20 ; g 427 f000 - .byte 8,18 ; g# 428 f000 - .byte 8,17 ; a 429 f000 - .byte 8,16 ; a# 430 f000 - .byte 8,15 ; b 431 f000 - 432 f000 - include "tiadrumkit.asm" 433 f000 - 434 f000 endif ;MUSICTRACKER ------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm 1163 f000 endif 1164 f000 ifnconst included.hiscore.asm ------- FILE hiscore.asm LEVEL 2 PASS 3 0 f000 include hiscore.asm 1 f000 ; Provided under the CC0 license. See the included LICENSE.txt for details. 2 f000 3 f000 - ifconst HSSUPPORT 4 f000 -detectatarivoxeeprom 5 f000 -hiscoremodulestart 6 f000 - ; do a test to see if atarivox eeprom can be accessed, and save results 7 f000 - jsr AVoxDetect 8 f000 - eor #$ff ; invert for easy 7800basic if...then logic 9 f000 - sta avoxdetected 10 f000 - lda #$0 11 f000 - sta SWACNT 12 f000 - lda avoxdetected 13 f000 - rts 14 f000 - 15 f000 -detecthsc 16 f000 - ; check for the HSC ROM signature... 17 f000 - lda XCTRL1s 18 f000 - ora #%00001100 19 f000 - sta XCTRL1s 20 f000 - sta XCTRL1 21 f000 - lda $3900 22 f000 - cmp #$C6 23 f000 - bne detecthscfail 24 f000 - lda $3904 25 f000 - cmp #$FE 26 f000 - bne detecthscfail 27 f000 - ; check if it's initialized... 28 f000 - ldy #0 29 f000 - lda #$ff 30 f000 -checkhscinit 31 f000 - and $1000,y 32 f000 - dey 33 f000 - bpl checkhscinit 34 f000 - cmp #$ff 35 f000 - bne hscisalreadyinit 36 f000 - ; if we're here, we need to do a minimal HSC init... 37 f000 - ldy #$28 38 f000 -hscinitloop1 39 f000 - lda hscheader,y 40 f000 - sta $1000,y 41 f000 - dey 42 f000 - bpl hscinitloop1 43 f000 - ldy #$89 44 f000 - lda #$7F 45 f000 -hscinitloop2 46 f000 - sta $10B3,y 47 f000 - dey 48 f000 - cpy #$ff 49 f000 - bne hscinitloop2 50 f000 -hscisalreadyinit 51 f000 - lda #$ff 52 f000 - rts 53 f000 -hscheader 54 f000 - .byte $00,$00,$68,$83,$AA,$55,$9C,$FF,$07,$12,$02,$1F,$00,$00,$00,$00 55 f000 - .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 56 f000 - .byte $00,$00,$00,$00,$00,$00,$00,$00,$03 57 f000 -detecthscfail 58 f000 - lda XCTRL1s 59 f000 - and #%11110111 60 f000 - sta XCTRL1s 61 f000 - lda #0 62 f000 - rts 63 f000 endif ; HSSUPPORT 64 f000 65 f000 - ifconst HSSUPPORT 66 f000 - ifnconst hiscorefont 67 f000 - echo "" 68 f000 - echo "WARNING: High score support is enabled, but the hiscorefont.png was" 69 f000 - echo " NOT imported with incgraphic. The high score display code" 70 f000 - echo " has been omitted from this build." 71 f000 - echo "" 72 f000 - else 73 f000 -hscdrawscreen 74 f000 - 75 f000 - ; we use 20 lines on a 24 line display 76 f000 - ; HSSCOREY to dynamically centers based on 77 f000 - ;HSSCOREY = 0 78 f000 -HSSCOREY = ((WZONECOUNT*WZONEHEIGHT/8)-22)/2 79 f000 -HSCURSORY = ((HSSCOREY/(WZONEHEIGHT/8))*WZONEHEIGHT) 80 f000 - 81 f000 - ifconst HSSCORESIZE 82 f000 -SCORESIZE = HSSCORESIZE 83 f000 - else 84 f000 -SCORESIZE = 6 85 f000 - endif 86 f000 - 87 f000 - ;save shadow registers for later return... 88 f000 - lda sCTRL 89 f000 - sta ssCTRL 90 f000 - lda sCHARBASE 91 f000 - sta ssCHARBASE 92 f000 - lda #$60 93 f000 - sta charactermode 94 f000 - jsr drawwait 95 f000 - jsr blacken320colors 96 f000 - jsr clearscreen 97 f000 - 98 f000 - ;set the character base to the HSC font 99 f000 - lda #>hiscorefont 100 f000 - sta CHARBASE 101 f000 - sta sCHARBASE 102 f000 - lda #%01000011 ;Enable DMA, mode=320A 103 f000 - sta CTRL 104 f000 - sta sCTRL 105 f000 - 106 f000 - lda #60 107 f000 - sta hsjoydebounce 108 f000 - 109 f000 - lda #0 110 f000 - sta hscursorx 111 f000 - sta framecounter 112 f000 - ifnconst HSCOLORCHASESTART 113 f000 - lda #$8D ; default is blue. why not? 114 f000 - else 115 f000 - lda #HSCOLORCHASESTART 116 f000 - endif 117 f000 - sta hscolorchaseindex 118 f000 - 119 f000 - lda #$0F 120 f000 - sta P0C2 ; base text is white 121 f000 - 122 f000 - jsr hschasecolors 123 f000 - ; ** plot all of the initials 124 f000 - lda #HSRAMInitials 127 f000 - sta temp2 ; charmaphi 128 f000 - lda #32+29 ; palette=0-29 | 32-(width=3) 129 f000 - sta temp3 ; palette/width 130 f000 - lda #104 131 f000 - sta temp4 ; X 132 f000 - lda #((HSSCOREY+6)/(WZONEHEIGHT/8)) 133 f000 - sta temp5 ; Y 134 f000 -plothsinitialsloop 135 f000 - jsr plotcharacters 136 f000 - clc 137 f000 - lda temp3 138 f000 - adc #32 139 f000 - sta temp3 140 f000 - inc temp5 141 f000 - if WZONEHEIGHT = 8 142 f000 - inc temp5 143 f000 - endif 144 f000 - clc 145 f000 - lda #3 146 f000 - adc temp1 147 f000 - sta temp1 148 f000 - cmp #(<(HSRAMInitials+15)) 149 f000 - bcc plothsinitialsloop 150 f000 - 151 f000 - ifconst HSGAMENAMELEN 152 f000 - ;plot the game name... 153 f000 - lda #HSGAMENAMEtable 156 f000 - sta temp2 ; charmaphi 157 f000 - lda #(32-HSGAMENAMELEN) ; palette=0*29 | 32-(width=3) 158 f000 - sta temp3 ; palette/width 159 f000 - lda #(80-(HSGAMENAMELEN*2)) 160 f000 - sta temp4 ; X 161 f000 - lda #((HSSCOREY+0)/(WZONEHEIGHT/8)) 162 f000 - sta temp5 ; Y 163 f000 - jsr plotcharacters 164 f000 - endif ; HSGAMENAMELEN 165 f000 - 166 f000 - ;plot "difficulty"... 167 f000 - ldy gamedifficulty 168 f000 - ifnconst HSNOLEVELNAMES 169 f000 - lda highscoredifficultytextlo,y 170 f000 - sta temp1 171 f000 - lda highscoredifficultytexthi,y 172 f000 - sta temp2 173 f000 - sec 174 f000 - lda #32 175 f000 - sbc highscoredifficultytextlen,y 176 f000 - sta temp3 ; palette/width 177 f000 - sec 178 f000 - lda #40 179 f000 - sbc highscoredifficultytextlen,y 180 f000 - asl 181 f000 - sta temp4 ; X 182 f000 - else 183 f000 - lda #HSHIGHSCOREStext 186 f000 - sta temp2 ; charmaphi 187 f000 - lda #(32-11) ; palette=0*29 | 32-(width=3) 188 f000 - sta temp3 ; palette/width 189 f000 - lda #(80-(11*2)) 190 f000 - sta temp4 ; X 191 f000 - endif ; HSNOLEVELNAMES 192 f000 - 193 f000 - lda #((HSSCOREY+2)/(WZONEHEIGHT/8)) 194 f000 - sta temp5 ; Y 195 f000 - jsr plotcharacters 196 f000 - ldy hsdisplaymode ; 0=attact mode, 1=player eval, 2=player 1 eval, 3=player 2 player eval 197 f000 - bne carronwithscoreevaluation 198 f000 - jmp donoscoreevaluation 199 f000 -carronwithscoreevaluation 200 f000 - dey 201 f000 - lda highscorelabeltextlo,y 202 f000 - sta temp1 203 f000 - lda highscorelabeltexthi,y 204 f000 - sta temp2 205 f000 - sec 206 f000 - lda #(32-15) ; palette=0*29 | 32-(width=3) 207 f000 - sta temp3 ; palette/width 208 f000 - lda highscorelabeladjust1,y 209 f000 - sta temp4 ; X 210 f000 - lda #((HSSCOREY+18)/(WZONEHEIGHT/8)) 211 f000 - sta temp5 ; Y 212 f000 - jsr plotcharacters 213 f000 - 214 f000 - ldy hsdisplaymode ; 0=attact mode, 1=player eval, 2=player 1 eval, 3=player 2 player eval 215 f000 - dey 216 f000 - ;plot the current player score... 217 f000 - lda #(32-SCORESIZE) ; palette=0*32 218 f000 - sta temp3 ; palette/width 219 f000 - lda highscorelabeladjust2,y 220 f000 - sta temp4 ; X 221 f000 - lda #((HSSCOREY+18)/(WZONEHEIGHT/8)) 222 f000 - sta temp5 ; Y 223 f000 - 224 f000 - lda scorevarlo,y 225 f000 - sta temp7 ; score variable lo 226 f000 - lda scorevarhi,y 227 f000 - sta temp8 ; score variable hi 228 f000 - 229 f000 - lda #(hiscorefont_mode | %01100000) ; charactermode 230 f000 - sta temp9 231 f000 - 232 f000 - lda #<(hiscorefont+33) ; +33 to get to '0' character 233 f000 - sta temp1 ; charmaplo 234 f000 - lda #>(hiscorefont+33) 235 f000 - sta temp2 ; charmaphi 236 f000 - lda #SCORESIZE 237 f000 - sta temp6 238 f000 - ifnconst DOUBLEWIDE 239 f000 - jsr plotvalue 240 f000 - else 241 f000 - jsr plotvaluedw 242 f000 - endif 243 f000 - 244 f000 -USED_PLOTVALUE = 1 ; ensure that plotvalue gets compiled in 245 f000 - 246 f000 - ifconst HSGAMERANKS 247 f000 - 248 f000 - ldx #$ff ; start at 0 after the inx... 249 f000 -comparescore2rankloop 250 f000 - inx 251 f000 - ldy #0 252 f000 - lda rankvalue_0,x 253 f000 - cmp (temp7),y 254 f000 - bcc score2rankloopdone 255 f000 - bne comparescore2rankloop 256 f000 - iny 257 f000 - lda rankvalue_1,x 258 f000 - cmp (temp7),y 259 f000 - bcc score2rankloopdone 260 f000 - bne comparescore2rankloop 261 f000 - iny 262 f000 - lda (temp7),y 263 f000 - cmp rankvalue_2,x 264 f000 - bcs score2rankloopdone 265 f000 - jmp comparescore2rankloop 266 f000 -score2rankloopdone 267 f000 - stx hsnewscorerank 268 f000 - 269 f000 - lda ranklabello,x 270 f000 - sta temp1 271 f000 - lda ranklabelhi,x 272 f000 - sta temp2 273 f000 - sec 274 f000 - lda #32 ; palette=0*29 | 32-(width=3) 275 f000 - sbc ranklabellengths,x 276 f000 - sta temp3 ; palette/width 277 f000 - sec 278 f000 - lda #(40+6) 279 f000 - sbc ranklabellengths,x 280 f000 - asl 281 f000 - sta temp4 ; X 282 f000 - lda #((HSSCOREY+20)/(WZONEHEIGHT/8)) 283 f000 - sta temp5 ; Y 284 f000 - jsr plotcharacters 285 f000 - 286 f000 - ldx hsnewscorerank 287 f000 - 288 f000 - lda #highscoreranklabel 291 f000 - sta temp2 292 f000 - 293 f000 - lda #(32-5) ; palette=0*29 | 32-(width=3) 294 f000 - sta temp3 ; palette/width 295 f000 - lda #(40-6) 296 f000 - sec 297 f000 - sbc ranklabellengths,x 298 f000 - asl 299 f000 - sta temp4 ; X 300 f000 - lda #((HSSCOREY+20)/(WZONEHEIGHT/8)) 301 f000 - sta temp5 ; Y 302 f000 - jsr plotcharacters 303 f000 - endif 304 f000 - 305 f000 - 306 f000 - ; ** which line did this player beat? 307 f000 - lda #$ff 308 f000 - sta hsnewscoreline 309 f000 - ldx #$fd 310 f000 -comparescoreadd2x 311 f000 - inx 312 f000 -comparescoreadd1x 313 f000 - inx 314 f000 -comparescore2lineloop 315 f000 - inc hsnewscoreline 316 f000 - inx ; initialrun, x=0 317 f000 - cpx #15 318 f000 - beq nohighscoreforyou 319 f000 - ldy #0 320 f000 - lda HSRAMScores,x 321 f000 - cmp (temp7),y ; first score digit 322 f000 - bcc score2lineloopdonedel1x 323 f000 - bne comparescoreadd2x 324 f000 - iny 325 f000 - inx 326 f000 - lda HSRAMScores,x 327 f000 - cmp (temp7),y 328 f000 - bcc score2lineloopdonedel2x 329 f000 - bne comparescoreadd1x 330 f000 - iny 331 f000 - inx 332 f000 - lda (temp7),y 333 f000 - cmp HSRAMScores,x 334 f000 - bcs score2lineloopdonedel3x 335 f000 - jmp comparescore2lineloop 336 f000 -nohighscoreforyou 337 f000 - lda #$ff 338 f000 - sta hsnewscoreline 339 f000 - sta countdownseconds 340 f000 - jmp donoscoreevaluation 341 f000 -score2lineloopdonedel3x 342 f000 - dex 343 f000 -score2lineloopdonedel2x 344 f000 - dex 345 f000 -score2lineloopdonedel1x 346 f000 - dex 347 f000 - 348 f000 - ; 0 1 2 349 f000 - ; 3 4 5 350 f000 - ; 6 7 8 351 f000 - ; 9 0 1 352 f000 - ; 2 3 4 353 f000 - 354 f000 - stx temp9 355 f000 - cpx #11 356 f000 - beq postsortscoresuploop 357 f000 - ldx #11 358 f000 -sortscoresuploop 359 f000 - lda HSRAMScores,x 360 f000 - sta HSRAMScores+3,x 361 f000 - lda HSRAMInitials,x 362 f000 - sta HSRAMInitials+3,x 363 f000 - dex 364 f000 - cpx temp9 365 f000 - bne sortscoresuploop 366 f000 -postsortscoresuploop 367 f000 - 368 f000 - ;stick the score and cleared initials in the slot... 369 f000 - inx 370 f000 - ldy #0 371 f000 - sty hsinitialhold 372 f000 - lda (temp7),y 373 f000 - sta HSRAMScores,x 374 f000 - iny 375 f000 - lda (temp7),y 376 f000 - sta HSRAMScores+1,x 377 f000 - iny 378 f000 - lda (temp7),y 379 f000 - sta HSRAMScores+2,x 380 f000 - lda #0 381 f000 - sta HSRAMInitials,x 382 f000 - lda #29 383 f000 - sta HSRAMInitials+1,x 384 f000 - sta HSRAMInitials+2,x 385 f000 - 386 f000 - stx hsinitialpos 387 f000 - 388 f000 - ifconst vox_highscore 389 f000 - lda <#vox_highscore 390 f000 - sta speech_addr 391 f000 - lda >#vox_highscore 392 f000 - sta speech_addr+1 393 f000 - endif 394 f000 - ifconst sfx_highscore 395 f000 - lda <#sfx_highscore 396 f000 - sta temp1 397 f000 - lda >#sfx_highscore 398 f000 - sta temp2 399 f000 - lda #0 400 f000 - sta temp3 401 f000 - jsr schedulesfx 402 f000 - endif 403 f000 - ifconst songdatastart_song_highscore 404 f000 - lda #songchanneltable_song_highscore 407 f000 - sta songpointerhi 408 f000 - lda #73 409 f000 - sta songtempo 410 f000 - jsr setsongchannels 411 f000 - endif 412 f000 - 413 f000 - 414 f000 -donoscoreevaluation 415 f000 - 416 f000 - lda #(32+(32-SCORESIZE)) ; palette=0*32 | 32-(width=6) 417 f000 - sta temp3 ; palette/width 418 f000 - lda #(72+(4*(6-SCORESIZE))) 419 f000 - sta temp4 ; X 420 f000 - lda #((HSSCOREY+6)/(WZONEHEIGHT/8)) 421 f000 - sta temp5 ; Y 422 f000 - lda #HSRAMScores 425 f000 - sta temp8 ; score variable hi 426 f000 - lda #(hiscorefont_mode | %01100000) ; charactermode 427 f000 - sta temp9 428 f000 -plothsscoresloop 429 f000 - lda #<(hiscorefont+33) ; +33 to get to '0' character 430 f000 - sta temp1 ; charmaplo 431 f000 - lda #>(hiscorefont+33) 432 f000 - sta temp2 ; charmaphi 433 f000 - lda #6 434 f000 - sta temp6 435 f000 - ifnconst DOUBLEWIDE 436 f000 - jsr plotvalue 437 f000 - else 438 f000 - jsr plotvaluedw 439 f000 - endif 440 f000 - clc 441 f000 - lda temp3 442 f000 - adc #32 443 f000 - sta temp3 444 f000 - inc temp5 445 f000 - if WZONEHEIGHT = 8 446 f000 - inc temp5 447 f000 - endif 448 f000 - clc 449 f000 - lda #3 450 f000 - adc temp7 451 f000 - sta temp7 452 f000 - cmp #(<(HSRAMScores+15)) 453 f000 - bcc plothsscoresloop 454 f000 -plothsindex 455 f000 - lda #32+31 ; palette=0*32 | 32-(width=1) 456 f000 - sta temp3 ; palette/width 457 f000 - lda #44 458 f000 - sta temp4 ; X 459 f000 - lda #((HSSCOREY+6)/(WZONEHEIGHT/8)) 460 f000 - sta temp5 ; Y 461 f000 - lda #hsgameslotnumbers 464 f000 - sta temp8 ; score variable hi 465 f000 - lda #(hiscorefont_mode | %01100000) ; charactermode 466 f000 - sta temp9 467 f000 -plothsindexloop 468 f000 - lda #<(hiscorefont+33) 469 f000 - sta temp1 ; charmaplo 470 f000 - lda #>(hiscorefont+33) 471 f000 - sta temp2 ; charmaphi 472 f000 - lda #1 473 f000 - sta temp6 ; number of characters 474 f000 - ifnconst DOUBLEWIDE 475 f000 - jsr plotvalue 476 f000 - else 477 f000 - jsr plotvaluedw 478 f000 - endif 479 f000 - clc 480 f000 - lda temp3 481 f000 - adc #32 482 f000 - sta temp3 483 f000 - inc temp5 484 f000 - if WZONEHEIGHT = 8 485 f000 - inc temp5 486 f000 - endif 487 f000 - inc temp7 488 f000 - lda temp7 489 f000 - cmp #(<(hsgameslotnumbers+5)) 490 f000 - bcc plothsindexloop 491 f000 - 492 f000 - jsr savescreen 493 f000 - ifnconst HSSECONDS 494 f000 - lda #6 495 f000 - else 496 f000 - lda #HSSECONDS 497 f000 - endif 498 f000 - 499 f000 - sta countdownseconds 500 f000 - 501 f000 -keepdisplayinghs 502 f000 - jsr restorescreen 503 f000 - 504 f000 - jsr setuphsinpt1 505 f000 - 506 f000 - lda hsnewscoreline 507 f000 - bpl carryonkeepdisplayinghs 508 f000 - jmp skipenterscorecontrol 509 f000 -carryonkeepdisplayinghs 510 f000 - 511 f000 - 512 f000 - ifnconst HSSECONDS 513 f000 - lda #6 514 f000 - else 515 f000 - lda #HSSECONDS 516 f000 - endif 517 f000 - 518 f000 - sta countdownseconds 519 f000 - 520 f000 - ;plot the "cursor" initial sprite... 521 f000 - lda hsinitialhold 522 f000 - 523 f000 - sta temp1 524 f000 - lda #>(hiscorefont+32) 525 f000 - sta temp2 526 f000 - lda #31 ; palette=0*32 | 32-(width=1) 527 f000 - sta temp3 ; palette/width 528 f000 - lda hscursorx 529 f000 - asl 530 f000 - asl 531 f000 - clc 532 f000 - adc #104 533 f000 - sta temp4 ; X 534 f000 - lda hsnewscoreline 535 f000 - asl 536 f000 - asl 537 f000 - asl 538 f000 - asl 539 f000 - adc #((3*16)+HSCURSORY) 540 f000 - sta temp5 ; Y 541 f000 - lda #%01000000 542 f000 - sta temp6 543 f000 - jsr plotsprite 544 f000 - 545 f000 - ldx hscursorx 546 f000 - ldy hsdisplaymode 547 f000 - lda SWCHA 548 f000 - cpy #3 549 f000 - bne hsskipadjustjoystick1 550 f000 - asl 551 f000 - asl 552 f000 - asl 553 f000 - asl 554 f000 -hsskipadjustjoystick1 555 f000 - sta hsswcha 556 f000 - lda SWCHB 557 f000 - and #%00000010 558 f000 - bne hsskipselectswitch 559 f000 - lda #%00010000 560 f000 - sta hsswcha 561 f000 - bne hsdodebouncecheck 562 f000 -hsskipselectswitch 563 f000 - lda hsswcha 564 f000 - and #%00110000 565 f000 - cmp #%00110000 566 f000 - beq hsjoystickskipped 567 f000 -hsdodebouncecheck 568 f000 - lda hsjoydebounce 569 f000 - beq hsdontdebounce 570 f000 - jmp hspostjoystick 571 f000 -hsdontdebounce 572 f000 - ldx #1 ; small tick sound 573 f000 - jsr playhssfx 574 f000 - lda hsswcha 575 f000 - and #%00110000 576 f000 - ldx hscursorx 577 f000 - cmp #%00100000 ; check down 578 f000 - bne hsjoycheckup 579 f000 - ldy hsinitialhold 580 f000 - cpx #0 581 f000 - bne skipavoid31_1 582 f000 - cpy #0 ; if we're about to change to the <- char (#31) then double-decrement to skip over it 583 f000 - bne skipavoid31_1 584 f000 - dey 585 f000 -skipavoid31_1 586 f000 - dey 587 f000 - jmp hssetdebounce 588 f000 -hsjoycheckup 589 f000 - cmp #%00010000 ; check up 590 f000 - bne hsjoystickskipped 591 f000 - ldy hsinitialhold 592 f000 - cpx #0 593 f000 - bne skipavoid31_2 594 f000 - cpy #30 ; if we're about to change to the <- char (#31) then double-increment to skip over it 595 f000 - bne skipavoid31_2 596 f000 - iny 597 f000 -skipavoid31_2 598 f000 - iny 599 f000 -hssetdebounce 600 f000 - tya 601 f000 - and #31 602 f000 - sta hsinitialhold 603 f000 - lda #15 604 f000 - sta hsjoydebounce 605 f000 - bne hspostjoystick 606 f000 -hsjoystickskipped 607 f000 - ; check the fire button only when the stick isn't engaged 608 f000 - lda hsinpt1 609 f000 - bpl hsbuttonskipped 610 f000 - lda hsjoydebounce 611 f000 - beq hsfiredontdebounce 612 f000 - bne hspostjoystick 613 f000 -hsfiredontdebounce 614 f000 - lda hsinitialhold 615 f000 - cmp #31 616 f000 - beq hsmovecursorback 617 f000 - inc hscursorx 618 f000 - inc hsinitialpos 619 f000 - lda hscursorx 620 f000 - cmp #3 621 f000 - bne skiphsentryisdone 622 f000 - lda #0 623 f000 - sta framecounter 624 f000 - lda #$ff 625 f000 - sta hsnewscoreline 626 f000 - dec hsinitialpos 627 f000 - bne skiphsentryisdone 628 f000 -hsmovecursorback 629 f000 - lda hscursorx 630 f000 - beq skiphsmovecursorback 631 f000 - lda #29 632 f000 - ldx hsinitialpos 633 f000 - sta HSRAMInitials,x 634 f000 - dec hsinitialpos 635 f000 - dec hscursorx 636 f000 - dex 637 f000 - lda HSRAMInitials,x 638 f000 - sta hsinitialhold 639 f000 -skiphsmovecursorback 640 f000 -skiphsentryisdone 641 f000 - ldx #0 642 f000 - jsr playhssfx 643 f000 - lda #20 644 f000 - sta hsjoydebounce 645 f000 - bne hspostjoystick 646 f000 - 647 f000 -hsbuttonskipped 648 f000 - lda #0 649 f000 - sta hsjoydebounce 650 f000 -hspostjoystick 651 f000 - 652 f000 - ldx hsinitialpos 653 f000 - lda hsinitialhold 654 f000 - sta HSRAMInitials,x 655 f000 - 656 f000 - jmp skiphschasecolors 657 f000 - 658 f000 -skipenterscorecontrol 659 f000 - jsr hschasecolors 660 f000 - jsr setuphsinpt1 661 f000 - lda hsjoydebounce 662 f000 - bne skiphschasecolors 663 f000 - lda hsinpt1 664 f000 - bmi returnfromhs 665 f000 -skiphschasecolors 666 f000 - 667 f000 - jsr drawscreen 668 f000 - 669 f000 - lda countdownseconds 670 f000 - beq returnfromhs 671 f000 - jmp keepdisplayinghs 672 f000 -returnfromhs 673 f000 - 674 f000 - ifconst songdatastart_song_highscore 675 f000 - lda hsdisplaymode 676 f000 - beq skipclearHSCsong 677 f000 - lda #0 678 f000 - sta songtempo 679 f000 -skipclearHSCsong 680 f000 - endif 681 f000 - jsr drawwait 682 f000 - jsr clearscreen 683 f000 - lda #0 684 f000 - ldy #7 685 f000 - jsr blacken320colors 686 f000 - lda ssCTRL 687 f000 - sta sCTRL 688 f000 - lda ssCHARBASE 689 f000 - sta sCHARBASE 690 f000 - rts 691 f000 - 692 f000 -setuphsinpt1 693 f000 - lda #$ff 694 f000 - sta hsinpt1 695 f000 - lda hsjoydebounce 696 f000 - beq skipdebounceadjust 697 f000 - dec hsjoydebounce 698 f000 - bne skipstorefirebuttonstatus 699 f000 -skipdebounceadjust 700 f000 - lda SWCHB 701 f000 - and #%00000001 702 f000 - bne hscheckresetover 703 f000 - lda #$ff 704 f000 - sta hsinpt1 705 f000 - rts 706 f000 -hscheckresetover 707 f000 - ldx hsdisplaymode 708 f000 - cpx #3 709 f000 - bne hsskipadjustjoyfire1 710 f000 - lda sINPT3 711 f000 - jmp hsskipadjustjoyfire1done 712 f000 -hsskipadjustjoyfire1 713 f000 - lda sINPT1 714 f000 -hsskipadjustjoyfire1done 715 f000 - sta hsinpt1 716 f000 -skipstorefirebuttonstatus 717 f000 - rts 718 f000 - 719 f000 -blacken320colors 720 f000 - ldy #7 721 f000 -blacken320colorsloop 722 f000 - sta P0C2,y 723 f000 - dey 724 f000 - bpl blacken320colorsloop 725 f000 - rts 726 f000 - 727 f000 -hschasecolors 728 f000 - lda framecounter 729 f000 - and #3 730 f000 - bne hschasecolorsreturn 731 f000 - inc hscolorchaseindex 732 f000 - lda hscolorchaseindex 733 f000 - 734 f000 - sta P5C2 735 f000 - sbc #$02 736 f000 - sta P4C2 737 f000 - sbc #$02 738 f000 - sta P3C2 739 f000 - sbc #$02 740 f000 - sta P2C2 741 f000 - sbc #$02 742 f000 - sta P1C2 743 f000 -hschasecolorsreturn 744 f000 - rts 745 f000 - 746 f000 -playhssfx 747 f000 - lda hssfx_lo,x 748 f000 - sta temp1 749 f000 - lda hssfx_hi,x 750 f000 - sta temp2 751 f000 - lda #0 752 f000 - sta temp3 753 f000 - jmp schedulesfx 754 f000 - 755 f000 -hssfx_lo 756 f000 - .byte sfx_hsletterpositionchange, >sfx_hslettertick 759 f000 - 760 f000 -sfx_hsletterpositionchange 761 f000 - .byte $10,$18,$00 762 f000 - .byte $02,$06,$08 763 f000 - .byte $02,$06,$04 764 f000 - .byte $00,$00,$00 765 f000 -sfx_hslettertick 766 f000 - .byte $10,$18,$00 767 f000 - .byte $00,$00,$0a 768 f000 - .byte $00,$00,$00 769 f000 - 770 f000 -highscorelabeladjust1 771 f000 - .byte (80-(14*2)-(SCORESIZE*2)),(80-(16*2)-(SCORESIZE*2)),(80-(16*2)-(SCORESIZE*2)) 772 f000 -highscorelabeladjust2 773 f000 - .byte (80+(14*2)-(SCORESIZE*2)),(80+(16*2)-(SCORESIZE*2)),(80+(16*2)-(SCORESIZE*2)) 774 f000 - 775 f000 -scorevarlo 776 f000 - .byte <(score0+((6-SCORESIZE)/2)),<(score0+((6-SCORESIZE)/2)),<(score1+((6-SCORESIZE)/2)) 777 f000 -scorevarhi 778 f000 - .byte >(score0+((6-SCORESIZE)/2)),>(score0+((6-SCORESIZE)/2)),>(score1+((6-SCORESIZE)/2)) 779 f000 - 780 f000 - ifnconst HSNOLEVELNAMES 781 f000 -highscoredifficultytextlo 782 f000 - .byte easylevelname, >mediumlevelname, >hardlevelname, >expertlevelname 785 f000 - ifnconst HSCUSTOMLEVELNAMES 786 f000 -highscoredifficultytextlen 787 f000 - .byte 22, 30, 26, 24 788 f000 - 789 f000 -easylevelname 790 f000 - .byte $04,$00,$12,$18,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12 791 f000 -mediumlevelname 792 f000 - .byte $08,$0d,$13,$04,$11,$0c,$04,$03,$08,$00,$13,$04,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12 793 f000 -hardlevelname 794 f000 - .byte $00,$03,$15,$00,$0d,$02,$04,$03,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12 795 f000 -expertlevelname 796 f000 - .byte $04,$17,$0f,$04,$11,$13,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12 797 f000 - else 798 f000 - include "7800hsgamediffnames.asm" 799 f000 - endif ; HSCUSTOMLEVELNAMES 800 f000 - else 801 f000 -HSHIGHSCOREStext 802 f000 - .byte $07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12 803 f000 - endif ; HSNOLEVELNAMES 804 f000 - 805 f000 -highscorelabeltextlo 806 f000 - .byte player0label, >player1label, >player2label 809 f000 - 810 f000 -player0label 811 f000 - .byte $0f,$0b,$00,$18,$04,$11,$1d,$12,$02,$0e,$11,$04,$1a,$1d,$1d 812 f000 - 813 f000 -player1label 814 f000 - .byte $0f,$0b,$00,$18,$04,$11,$1d,$22,$1d,$12,$02,$0e,$11,$04,$1a 815 f000 - 816 f000 -player2label 817 f000 - .byte $0f,$0b,$00,$18,$04,$11,$1d,$23,$1d,$12,$02,$0e,$11,$04,$1a 818 f000 - 819 f000 - 820 f000 - ifconst HSGAMENAMELEN 821 f000 -HSGAMENAMEtable 822 f000 - include "7800hsgamename.asm" 823 f000 - endif 824 f000 - ifconst HSGAMERANKS 825 f000 - include "7800hsgameranks.asm" 826 f000 -highscoreranklabel 827 f000 - .byte $11,$00,$0d,$0a,$1a 828 f000 - endif 829 f000 - 830 f000 - ;ensure our table doesn't wrap a page... 831 f000 - if ((<*)>251) 832 f000 - align 256 833 f000 - endif 834 f000 -hsgameslotnumbers 835 f000 - .byte 33,34,35,36,37 836 f000 - endif 837 f000 - 838 f000 -loaddifficultytable 839 f000 - lda gamedifficulty 840 f000 - and #$03 ; ensure the user hasn't selected an invalid difficulty 841 f000 - sta gamedifficulty 842 f000 - cmp hsdifficulty ; check game difficulty is the same as RAM table 843 f000 - bne loaddifficultytablecontinue1 844 f000 - rts ; this high score difficulty table is already loaded 845 f000 -loaddifficultytablecontinue1 846 f000 - lda gamedifficulty 847 f000 - sta hsdifficulty 848 f000 - ;we need to check the device for the table 849 f000 - lda hsdevice 850 f000 - bne loaddifficultytablecontinue2 851 f000 - ; there's no save device. clear out this table. 852 f000 - jmp cleardifficultytablemem 853 f000 -loaddifficultytablecontinue2 854 f000 - lda hsdevice 855 f000 - and #1 856 f000 - beq memdeviceisntHSC 857 f000 - jmp loaddifficultytableHSC 858 f000 -memdeviceisntHSC 859 f000 - jmp loaddifficultytableAVOX 860 f000 - 861 f000 -savedifficultytable 862 f000 - ;*** we need to check wich device we should use... 863 f000 - lda hsdevice 864 f000 - bne savedifficultytablerealdevice 865 f000 - rts ; its a ram device 866 f000 -savedifficultytablerealdevice 867 f000 - and #1 868 f000 - beq savememdeviceisntHSC 869 f000 - jmp savedifficultytableHSC 870 f000 -savememdeviceisntHSC 871 f000 - jmp savedifficultytableAVOX 872 f000 - 873 f000 -savedifficultytableAVOX 874 f000 - ; the load call already setup the memory structure and atarivox memory location 875 f000 - jsr savealoadedHSCtablecontinue 876 f000 -savedifficultytableAVOXskipconvert 877 f000 - lda #HSIDHI 878 f000 - sta eeprombuffer 879 f000 - lda #HSIDLO 880 f000 - sta eeprombuffer+1 881 f000 - lda hsdifficulty 882 f000 - sta eeprombuffer+2 883 f000 - lda #32 884 f000 - jsr AVoxWriteBytes 885 f000 - rts 886 f000 - 887 f000 -savedifficultytableHSC 888 f000 - ;we always load a table before reaching here, so the 889 f000 - ;memory structures from the load should be intact... 890 f000 - ldy hsgameslot 891 f000 - bpl savealoadedHSCtable 892 f000 - rts 893 f000 -savealoadedHSCtable 894 f000 - lda HSCGameDifficulty,y 895 f000 - cmp #$7F 896 f000 - bne savealoadedHSCtablecontinue 897 f000 - jsr initializeHSCtableentry 898 f000 -savealoadedHSCtablecontinue 899 f000 - ;convert our RAM table to HSC format and write it out... 900 f000 - ldy #0 901 f000 - ldx #0 902 f000 -savedifficultytableScores 903 f000 - 904 f000 - lda HSRAMInitials,x 905 f000 - sta temp3 906 f000 - lda HSRAMInitials+1,x 907 f000 - sta temp4 908 f000 - lda HSRAMInitials+2,x 909 f000 - sta temp5 910 f000 - jsr encodeHSCInitials ; takes 3 byte initials from temp3,4,5 and stores 2 byte initials in temp1,2 911 f000 - 912 f000 - lda temp1 913 f000 - sta (HSGameTableLo),y 914 f000 - iny 915 f000 - lda temp2 916 f000 - sta (HSGameTableLo),y 917 f000 - iny 918 f000 - 919 f000 - lda HSRAMScores,x 920 f000 - sta (HSGameTableLo),y 921 f000 - iny 922 f000 - lda HSRAMScores+1,x 923 f000 - sta (HSGameTableLo),y 924 f000 - iny 925 f000 - lda HSRAMScores+2,x 926 f000 - sta (HSGameTableLo),y 927 f000 - iny 928 f000 - inx 929 f000 - inx 930 f000 - inx ; +3 931 f000 - cpx #15 932 f000 - bne savedifficultytableScores 933 f000 - rts 934 f000 - 935 f000 -loaddifficultytableHSC 936 f000 - ; routine responsible for loading the difficulty table from HSC 937 f000 - jsr findindexHSC 938 f000 - ldy hsgameslot 939 f000 - lda HSCGameDifficulty,y 940 f000 - cmp #$7F 941 f000 - bne loaddifficultytableHSCcontinue 942 f000 - ;there was an error. use a new RAM table instead... 943 f000 - jmp cleardifficultytablemem 944 f000 -loaddifficultytableHSCcontinue 945 f000 - ; parse the data into the HS memory... 946 f000 - ldy #0 947 f000 - ldx #0 948 f000 -loaddifficultytableScores 949 f000 - lda (HSGameTableLo),y 950 f000 - sta temp1 951 f000 - iny 952 f000 - lda (HSGameTableLo),y 953 f000 - sta temp2 954 f000 - jsr decodeHSCInitials ; takes 2 byte initials from temp1,2 and stores 3 byte initials in temp3,4,5 955 f000 - iny 956 f000 - lda (HSGameTableLo),y 957 f000 - sta HSRAMScores,x 958 f000 - lda temp3 959 f000 - sta HSRAMInitials,x 960 f000 - inx 961 f000 - iny 962 f000 - lda (HSGameTableLo),y 963 f000 - sta HSRAMScores,x 964 f000 - lda temp4 965 f000 - sta HSRAMInitials,x 966 f000 - inx 967 f000 - iny 968 f000 - lda (HSGameTableLo),y 969 f000 - sta HSRAMScores,x 970 f000 - lda temp5 971 f000 - sta HSRAMInitials,x 972 f000 - inx 973 f000 - iny 974 f000 - cpx #15 975 f000 - bne loaddifficultytableScores 976 f000 - rts 977 f000 - 978 f000 -decodeHSCInitials 979 f000 - ; takes 2 byte initials from temp1,2 and stores 3 byte initials in temp3,4,5 980 f000 - ; 2 bytes are packed in the form: 22211111 22_33333 981 f000 - lda #0 982 f000 - sta temp4 983 f000 - lda temp1 984 f000 - and #%00011111 985 f000 - sta temp3 986 f000 - 987 f000 - lda temp2 988 f000 - and #%00011111 989 f000 - sta temp5 990 f000 - 991 f000 - lda temp1 992 f000 - asl 993 f000 - rol temp4 994 f000 - asl 995 f000 - rol temp4 996 f000 - asl 997 f000 - rol temp4 998 f000 - lda temp2 999 f000 - asl 1000 f000 - rol temp4 1001 f000 - asl 1002 f000 - rol temp4 1003 f000 - rts 1004 f000 -encodeHSCInitials 1005 f000 - ; takes 3 byte initials from temp3,4,5 and stores 2 byte initials in temp1,2 1006 f000 - ; 2 bytes are packed in the form: 22211111 22_33333 1007 f000 - ; start with packing temp1... 1008 f000 - lda temp4 1009 f000 - and #%00011100 1010 f000 - sta temp1 1011 f000 - asl temp1 1012 f000 - asl temp1 1013 f000 - asl temp1 1014 f000 - lda temp3 1015 f000 - and #%00011111 1016 f000 - ora temp1 1017 f000 - sta temp1 1018 f000 - ; ...temp1 is now packed, on to temp2... 1019 f000 - lda temp5 1020 f000 - asl 1021 f000 - asl 1022 f000 - ror temp4 1023 f000 - ror 1024 f000 - ror temp4 1025 f000 - ror 1026 f000 - sta temp2 1027 f000 - rts 1028 f000 - 1029 f000 -findindexHSCerror 1030 f000 - ;the HSC is stuffed. return the bad slot flag 1031 f000 - ldy #$ff 1032 f000 - sty hsgameslot 1033 f000 - rts 1034 f000 - 1035 f000 -findindexHSC 1036 f000 -HSCGameID1 = $1029 1037 f000 -HSCGameID2 = $106E 1038 f000 -HSCGameDifficulty = $10B3 1039 f000 -HSCGameIndex = $10F8 1040 f000 - ; routine responsible for finding the game index from HSC 1041 f000 - ; call with x=0 to create a new table if none exist, call with x=$ff to avoid creating new tables 1042 f000 - ; the HS loading routine will use x=$ff, the HS saving routine will use x=0 1043 f000 - ldy #69 ; start +1 to account for the dey 1044 f000 -findindexHSCloop 1045 f000 - dey 1046 f000 - bmi findindexHSCerror 1047 f000 - lda HSCGameDifficulty,y 1048 f000 - cmp #$7F 1049 f000 - beq findourindexHSC 1050 f000 - cmp gamedifficulty 1051 f000 - bne findindexHSCloop 1052 f000 - lda HSCGameID1,y 1053 f000 - cmp #HSIDHI 1054 f000 - bne findindexHSCloop 1055 f000 - lda HSCGameID2,y 1056 f000 - cmp #HSIDLO 1057 f000 - bne findindexHSCloop 1058 f000 -findourindexHSC 1059 f000 - ; if we're here we found our index in the table 1060 f000 - ; or we found the first empty one 1061 f000 - sty hsgameslot 1062 f000 - jsr setupHSCGamepointer ; setup the pointer to the HS Table for this game... 1063 f000 - rts 1064 f000 - 1065 f000 - 1066 f000 -initializeHSCtableentry 1067 f000 - ldy hsgameslot 1068 f000 - ; we need to make a new entry... 1069 f000 - lda #HSIDHI 1070 f000 - sta HSCGameID1,y 1071 f000 - lda #HSIDLO 1072 f000 - sta HSCGameID2,y 1073 f000 - lda gamedifficulty 1074 f000 - sta HSCGameDifficulty,y 1075 f000 - ldx #0 1076 f000 -fixHSDGameDifficultylistLoop 1077 f000 - inx 1078 f000 - txa 1079 f000 - sta HSCGameIndex,y 1080 f000 - iny 1081 f000 - cpy #69 1082 f000 - bne fixHSDGameDifficultylistLoop 1083 f000 - rts 1084 f000 - 1085 f000 -setupHSCGamepointer 1086 f000 - ; this routines sets (HSGameTableLo) pointing to the game's HS table 1087 f000 - lda #$17 1088 f000 - sta HSGameTableHi 1089 f000 - lda #$FA 1090 f000 - sta HSGameTableLo 1091 f000 -setupHSCGamepointerLoop 1092 f000 - lda HSGameTableLo 1093 f000 - sec 1094 f000 - sbc #25 1095 f000 - sta HSGameTableLo 1096 f000 - lda HSGameTableHi 1097 f000 - sbc #0 1098 f000 - sta HSGameTableHi 1099 f000 - iny 1100 f000 - cpy #69 1101 f000 - bne setupHSCGamepointerLoop 1102 f000 - rts 1103 f000 - 1104 f000 -loaddifficultytableAVOX 1105 f000 - ; routine responsible for loading the difficulty table from Avox 1106 f000 - ; we reuse HSC routines to format data to/from our Avox RAM buffer... 1107 f000 - lda #>(eeprombuffer+3) 1108 f000 - sta HSGameTableHi 1109 f000 - lda #<(eeprombuffer+3) 1110 f000 - sta HSGameTableLo 1111 f000 - 1112 f000 - ; the start location in EEPROM, subtract 32... 1113 f000 - lda #$5F 1114 f000 - sta HSVoxHi 1115 f000 - lda #$E0 1116 f000 - sta HSVoxLo 1117 f000 - lda #0 1118 f000 - sta temp1 1119 f000 -loaddifficultytableAVOXloop 1120 f000 - inc temp1 1121 f000 - beq loaddifficultytableAVOXfull 1122 f000 - clc 1123 f000 - lda HSVoxLo 1124 f000 - adc #32 1125 f000 - sta HSVoxLo 1126 f000 - lda HSVoxHi 1127 f000 - adc #0 1128 f000 - sta HSVoxHi 1129 f000 - lda #3 1130 f000 - jsr AVoxReadBytes ; read in 3 bytes, ID1,ID2,Difficulty 1131 f000 - lda eeprombuffer 1132 f000 - cmp #$FF 1133 f000 - beq loaddifficultytableAVOXempty 1134 f000 - cmp #HSIDHI 1135 f000 - bne loaddifficultytableAVOXloop 1136 f000 - lda eeprombuffer+1 1137 f000 - cmp #HSIDLO 1138 f000 - bne loaddifficultytableAVOXloop 1139 f000 - lda eeprombuffer+2 1140 f000 - cmp gamedifficulty 1141 f000 - bne loaddifficultytableAVOXloop 1142 f000 -loaddifficultytableAVOXdone 1143 f000 - lda #32 1144 f000 - jsr AVoxReadBytes 1145 f000 - jsr loaddifficultytableHSCcontinue 1146 f000 - rts 1147 f000 -loaddifficultytableAVOXfull 1148 f000 - lda #0 1149 f000 - sta hsdevice ; looks like all 255 entries are taken... disable it. 1150 f000 -loaddifficultytableAVOXempty 1151 f000 - jmp cleardifficultytablemem 1152 f000 - rts 1153 f000 - 1154 f000 -cleardifficultytablemem 1155 f000 - ldy #29 1156 f000 - lda #0 1157 f000 -cleardifficultytablememloop 1158 f000 - sta HSRAMTable,y 1159 f000 - dey 1160 f000 - bpl cleardifficultytablememloop 1161 f000 - rts 1162 f000 -hiscoremoduleend 1163 f000 - 1164 f000 - echo " hiscore assembly: ",[(hiscoremoduleend-hiscoremodulestart)]d," bytes" 1165 f000 - 1166 f000 - ifconst DOUBLEWIDE 1167 f000 -plotvaluedw 1168 f000 -plotdigitcount = temp6 1169 f000 - lda #0 1170 f000 - tay 1171 f000 - ldx valbufend 1172 f000 - 1173 f000 - lda plotdigitcount 1174 f000 - and #1 1175 f000 - beq pvnibble2chardw 1176 f000 - lda #0 1177 f000 - sta VALBUFFER,x ; just in case we skip this digit 1178 f000 - beq pvnibble2char_skipnibbledw 1179 f000 - 1180 f000 -pvnibble2chardw 1181 f000 - ; high nibble... 1182 f000 - lda (temp7),y 1183 f000 - and #$f0 1184 f000 - lsr 1185 f000 - lsr 1186 f000 - lsr 1187 f000 - lsr 1188 f000 - 1189 f000 - clc 1190 f000 - adc temp1 ; add the offset to character graphics to our value 1191 f000 - sta VALBUFFER,x 1192 f000 - inx 1193 f000 - dec plotdigitcount 1194 f000 -pvnibble2char_skipnibbledw 1195 f000 - ; low nibble... 1196 f000 - lda (temp7),y 1197 f000 - and #$0f 1198 f000 - clc 1199 f000 - adc temp1 ; add the offset to character graphics to our value 1200 f000 - sta VALBUFFER,x 1201 f000 - inx 1202 f000 - iny 1203 f000 - 1204 f000 - dec plotdigitcount 1205 f000 - bne pvnibble2chardw 1206 f000 - ;point to the start of our valuebuffer 1207 f000 - clc 1208 f000 - lda #VALBUFFER 1212 f000 - adc #0 1213 f000 - sta temp2 1214 f000 - 1215 f000 - ;advance valbufend to the end of our value buffer 1216 f000 - stx valbufend 1217 f000 - 1218 f000 - ifnconst plotvalueonscreen 1219 f000 - jmp plotcharacters 1220 f000 - else 1221 f000 - jmp plotcharacterslive 1222 f000 - endif 1223 f000 - endif ; DOUBLEWIDE 1224 f000 - 1225 f000 endif ; HSSUPPORT 1226 f000 ------- FILE c:\Users\Shane\Documents\my7800projects\MK Smith Examples\MKSmith Example 01.78b.asm 1166 f000 endif 1167 f000 ; Provided under the CC0 license. See the included LICENSE.txt for details. 1168 f000 1169 f000 ;standard routimes needed for pretty much all games 1170 f000 1171 f000 ; some definitions used with "set debug color" 1172 f000 00 91 DEBUGCALC = $91 1173 f000 00 41 DEBUGWASTE = $41 1174 f000 00 c1 DEBUGDRAW = $C1 1175 f000 1176 f000 ;NMI and IRQ handlers 1177 f000 NMI 1178 f000 ;VISIBLEOVER is 255 while the screen is drawn, and 0 right after the visible screen is done. 1179 f000 48 pha ; save A 1180 f001 a5 4d lda visibleover 1181 f003 49 ff eor #255 1182 f005 85 4d sta visibleover 1183 f007 - ifconst DEBUGINTERRUPT 1184 f007 - and #$93 1185 f007 - sta BACKGRND 1186 f007 endif 1187 f007 ce b2 01 dec interruptindex 1188 f00a d0 03 bne skipreallyoffvisible 1189 f00c 4c 73 f0 jmp reallyoffvisible 1190 f00f skipreallyoffvisible 1191 f00f a5 4d lda visibleover 1192 f011 d0 03 bne carryontopscreenroutine 1193 f013 - ifconst .bottomscreenroutine 1194 f013 - jsr .bottomscreenroutine 1195 f013 endif 1196 f013 1197 f013 4c 65 f0 jmp skiptopscreenroutine 1198 f016 carryontopscreenroutine 1199 f016 8a txa ; save X+Y 1200 f017 48 pha 1201 f018 98 tya 1202 f019 48 pha 1203 f01a d8 cld 1204 f01b - ifconst .topscreenroutine 1205 f01b - jsr .topscreenroutine 1206 f01b endif 1207 f01b ifnconst CANARYOFF 1208 f01b ad c1 01 lda canary 1209 f01e f0 0c beq skipcanarytriggered 1210 f020 a9 45 lda #$45 1211 f022 85 20 sta BACKGRND 1212 f024 a9 60 lda #$60 1213 f026 85 3c sta CTRL 1214 f028 8d 07 21 sta sCTRL 1215 f02b 02 .byte.b $02 ; KIL/JAM 1216 f02c endif 1217 f02c skipcanarytriggered 1218 f02c ee 3e 21 inc frameslost ; this is balanced with a "dec frameslost" when drawscreen is called. 1219 f02f 1220 f02f ; ** Other important routines that need to regularly run, and can run onscreen. 1221 f02f ; ** Atarivox can't go here, because Maria might interrupt it while it's bit-banging. 1222 f02f 1223 f02f - ifconst LONGCONTROLLERREAD 1224 f02f -longcontrollerreads ; ** controllers that take a lot of time to read. We use much of the visible screen here. 1225 f02f - ldy port1control 1226 f02f - lda longreadtype,y 1227 f02f - beq LLRET1 1228 f02f - tay 1229 f02f - lda longreadroutinehiP1,y 1230 f02f - sta inttemp4 1231 f02f - lda longreadroutineloP1,y 1232 f02f - sta inttemp3 1233 f02f - jmp (inttemp3) 1234 f02f -LLRET1 1235 f02f - ldy port0control 1236 f02f - lda longreadtype,y 1237 f02f - beq LLRET0 1238 f02f - tay 1239 f02f - lda longreadroutinehiP0,y 1240 f02f - sta inttemp4 1241 f02f - lda longreadroutineloP0,y 1242 f02f - sta inttemp3 1243 f02f - jmp (inttemp3) 1244 f02f -LLRET0 1245 f02f - 1246 f02f - 1247 f02f - ifconst PADDLERANGE 1248 f02f -TIMEVAL = PADDLERANGE 1249 f02f - else 1250 f02f -TIMEVAL = 160 1251 f02f - endif 1252 f02f -TIMEOFFSET = 10 1253 f02f - 1254 f02f endif ; LONGCONTROLLERREAD 1255 f02f 1256 f02f 1257 f02f 20 e5 f1 jsr servicesfxchannels 1258 f032 - ifconst MUSICTRACKER 1259 f032 - jsr servicesong 1260 f032 endif ; MUSICTRACKER 1261 f032 1262 f032 ee a4 01 inc framecounter 1263 f035 ad a4 01 lda framecounter 1264 f038 29 3f and #63 1265 f03a d0 08 bne skipcountdownseconds 1266 f03c ad a5 01 lda countdownseconds 1267 f03f f0 03 beq skipcountdownseconds 1268 f041 ce a5 01 dec countdownseconds 1269 f044 skipcountdownseconds 1270 f044 1271 f044 a2 01 ldx #1 1272 f046 buttonreadloop 1273 f046 8a txa 1274 f047 48 pha 1275 f048 bc b7 01 ldy port0control,x 1276 f04b b9 c8 f1 lda buttonhandlerlo,y 1277 f04e 85 da sta inttemp3 1278 f050 b9 bd f1 lda buttonhandlerhi,y 1279 f053 85 db sta inttemp4 1280 f055 05 da ora inttemp3 1281 f057 f0 03 beq buttonreadloopreturn 1282 f059 6c da 00 jmp (inttemp3) 1283 f05c buttonreadloopreturn 1284 f05c 68 pla 1285 f05d aa tax 1286 f05e ca dex 1287 f05f 10 e5 bpl buttonreadloop 1288 f061 1289 f061 - ifconst KEYPADSUPPORT 1290 f061 - jsr keypadrowselect 1291 f061 endif ; KEYPADSUPPORT 1292 f061 1293 f061 1294 f061 - ifconst DOUBLEBUFFER 1295 f061 - lda doublebufferminimumframeindex 1296 f061 - beq skipdoublebufferminimumframeindexadjust 1297 f061 - dec doublebufferminimumframeindex 1298 f061 -skipdoublebufferminimumframeindexadjust 1299 f061 endif 1300 f061 1301 f061 68 pla 1302 f062 a8 tay 1303 f063 68 pla 1304 f064 aa tax 1305 f065 skiptopscreenroutine 1306 f065 68 pla 1307 f066 40 RTI 1308 f067 1309 f067 IRQ ; the only source of non-nmi is the BRK opcode. The only 1310 f067 ifnconst BREAKPROTECTOFF 1311 f067 a9 1a lda #$1A 1312 f069 85 20 sta BACKGRND 1313 f06b a9 60 lda #$60 1314 f06d 85 3c sta CTRL 1315 f06f 8d 07 21 sta sCTRL 1316 f072 02 .byte.b $02 ; KIL/JAM 1317 f073 - else 1318 f073 - RTI 1319 f073 endif 1320 f073 1321 f073 - ifconst LONGCONTROLLERREAD 1322 f073 - 1323 f073 -longreadtype 1324 f073 - .byte 0, 0, 0, 1 ; NONE PROLINE LIGHTGUN PADDLE 1325 f073 - .byte 2, 0, 3, 0 ; TRKBALL VCSSTICK DRIVING KEYPAD 1326 f073 - .byte 3, 3, 0 ; STMOUSE AMOUSE ATARIVOX 1327 f073 - 1328 f073 -longreadroutineloP0 1329 f073 - .byte LLRET0 ; 0 = no routine 1336 f073 - .byte >paddleport0update ; 1 = paddle 1337 f073 - .byte >trakball0update ; 2 = trackball 1338 f073 - .byte >mouse0update ; 3 = mouse 1339 f073 - 1340 f073 -longreadroutineloP1 1341 f073 - .byte LLRET1 ; 0 = no routine 1348 f073 - .byte >paddleport1update ; 1 = paddle 1349 f073 - .byte >trakball1update ; 2 = trackball 1350 f073 - .byte >mouse1update ; 3 = mouse 1351 f073 - 1352 f073 - 1353 f073 -SETTIM64T 1354 f073 - bne skipdefaulttime 1355 f073 - ifnconst PADDLESMOOTHINGOFF 1356 f073 - lda #(TIMEVAL+TIMEOFFSET+1) 1357 f073 - else 1358 f073 - lda #(TIMEVAL+TIMEOFFSET) 1359 f073 - endif 1360 f073 -skipdefaulttime 1361 f073 - tay 1362 f073 - dey 1363 f073 -.setTIM64Tloop 1364 f073 - sta TIM64T 1365 f073 - cpy INTIM 1366 f073 - bne .setTIM64Tloop 1367 f073 - rts 1368 f073 endif ; LONGCONTROLLERREAD 1369 f073 1370 f073 reallyoffvisible 1371 f073 85 24 sta WSYNC 1372 f075 1373 f075 a9 00 lda #0 1374 f077 85 4d sta visibleover 1375 f079 - ifconst DEBUGINTERRUPT 1376 f079 - sta BACKGRND 1377 f079 endif 1378 f079 1379 f079 a9 03 lda #3 1380 f07b 8d b2 01 sta interruptindex 1381 f07e 1382 f07e 8a txa 1383 f07f 48 pha 1384 f080 98 tya 1385 f081 48 pha 1386 f082 d8 cld 1387 f083 1388 f083 1389 f083 20 5f f1 jsr uninterruptableroutines 1390 f086 1391 f086 - ifconst .userinterrupt 1392 f086 - jsr .userinterrupt 1393 f086 endif 1394 f086 1395 f086 - ifconst KEYPADSUPPORT 1396 f086 - jsr keypadcolumnread 1397 f086 endif 1398 f086 1399 f086 68 pla 1400 f087 a8 tay 1401 f088 68 pla 1402 f089 aa tax 1403 f08a 68 pla 1404 f08b 40 RTI 1405 f08c 1406 f08c clearscreen 1407 f08c a2 0b ldx #(WZONECOUNT-1) 1408 f08e a9 00 lda #0 1409 f090 clearscreenloop 1410 f090 95 65 sta dlend,x 1411 f092 ca dex 1412 f093 10 fb bpl clearscreenloop 1413 f095 a9 00 lda #0 1414 f097 8d ad 01 sta valbufend ; clear the bcd value buffer 1415 f09a 8d ae 01 sta valbufendsave 1416 f09d 60 rts 1417 f09e 1418 f09e restorescreen 1419 f09e a2 0b ldx #(WZONECOUNT-1) 1420 f0a0 a9 00 lda #0 1421 f0a2 restorescreenloop 1422 f0a2 b5 82 lda dlendsave,x 1423 f0a4 95 65 sta dlend,x 1424 f0a6 ca dex 1425 f0a7 10 f9 bpl restorescreenloop 1426 f0a9 ad ae 01 lda valbufendsave 1427 f0ac 8d ad 01 sta valbufend 1428 f0af 60 rts 1429 f0b0 1430 f0b0 savescreen 1431 f0b0 a2 0b ldx #(WZONECOUNT-1) 1432 f0b2 savescreenloop 1433 f0b2 b5 65 lda dlend,x 1434 f0b4 95 82 sta dlendsave,x 1435 f0b6 ca dex 1436 f0b7 10 f9 bpl savescreenloop 1437 f0b9 ad ad 01 lda valbufend 1438 f0bc 8d ae 01 sta valbufendsave 1439 f0bf - ifconst DOUBLEBUFFER 1440 f0bf - lda doublebufferstate 1441 f0bf - beq savescreenrts 1442 f0bf - lda #1 1443 f0bf - sta doublebufferbufferdirty 1444 f0bf -savescreenrts 1445 f0bf endif ; DOUBLEBUFFER 1446 f0bf 60 rts 1447 f0c0 1448 f0c0 drawscreen 1449 f0c0 1450 f0c0 a9 00 lda #0 1451 f0c2 85 42 sta temp1 ; not B&W if we're here... 1452 f0c4 1453 f0c4 drawscreenwait 1454 f0c4 a5 4d lda visibleover 1455 f0c6 d0 fc bne drawscreenwait ; make sure the visible screen isn't being drawn 1456 f0c8 1457 f0c8 ;restore some registers in case the game changed them mid-screen... 1458 f0c8 ad 07 21 lda sCTRL 1459 f0cb 05 42 ora temp1 1460 f0cd 85 3c sta CTRL 1461 f0cf ad 0b 21 lda sCHARBASE 1462 f0d2 85 34 sta CHARBASE 1463 f0d4 1464 f0d4 ;ensure all of the display list is terminated... 1465 f0d4 20 45 f1 jsr terminatedisplaylist 1466 f0d7 1467 f0d7 ifnconst pauseroutineoff 1468 f0d7 20 e2 f0 jsr pauseroutine 1469 f0da endif ; pauseroutineoff 1470 f0da 1471 f0da ; Make sure the visible screen has *started* before we exit. That way we can rely on drawscreen 1472 f0da ; delaying a full frame, but still allowing time for basic calculations. 1473 f0da visiblescreenstartedwait 1474 f0da a5 4d lda visibleover 1475 f0dc f0 fc beq visiblescreenstartedwait 1476 f0de visiblescreenstartedwaitdone 1477 f0de ce 3e 21 dec frameslost ; ; this gets balanced with an "inc frameslost" by an NMI at the top of the screen 1478 f0e1 60 rts 1479 f0e2 1480 f0e2 ifnconst pauseroutineoff 1481 f0e2 ; check to see if pause was pressed and released 1482 f0e2 pauseroutine 1483 f0e2 ad b3 01 lda pausedisable 1484 f0e5 d0 4e bne leavepauseroutine 1485 f0e7 a9 08 lda #8 1486 f0e9 2c 82 02 bit SWCHB 1487 f0ec f0 29 beq pausepressed 1488 f0ee 1489 f0ee ifnconst SOFTRESETASPAUSEOFF 1490 f0ee ifnconst MOUSESUPPORT 1491 f0ee ifnconst TRAKBALLSUPPORT 1492 f0ee ad 80 02 lda SWCHA ; then check the soft "RESET" joysick code... 1493 f0f1 29 70 and #%01110000 ; _LDU 1494 f0f3 f0 22 beq pausepressed 1495 f0f5 endif 1496 f0f5 endif 1497 f0f5 endif 1498 f0f5 1499 f0f5 ;pause isn't pressed 1500 f0f5 a9 00 lda #0 1501 f0f7 8d ac 01 sta pausebuttonflag ; clear pause hold state in case its set 1502 f0fa 1503 f0fa ;check if we're in an already paused state 1504 f0fa ad 00 21 lda pausestate 1505 f0fd f0 36 beq leavepauseroutine ; nope, leave 1506 f0ff 1507 f0ff c9 01 cmp #1 ; last frame was the start of pausing 1508 f101 f0 2b beq enterpausestate2 ; move from state 1 to 2 1509 f103 1510 f103 c9 02 cmp #2 1511 f105 f0 34 beq carryonpausing 1512 f107 1513 f107 ;pausestate must be >2, which means we're ending an unpause 1514 f107 a9 00 lda #0 1515 f109 8d ac 01 sta pausebuttonflag 1516 f10c 8d 00 21 sta pausestate 1517 f10f ad 07 21 lda sCTRL 1518 f112 85 3c sta CTRL 1519 f114 4c 35 f1 jmp leavepauseroutine 1520 f117 1521 f117 pausepressed 1522 f117 ;pause is pressed 1523 f117 ad ac 01 lda pausebuttonflag 1524 f11a c9 ff cmp #$ff 1525 f11c f0 1d beq carryonpausing 1526 f11e 1527 f11e ;its a new press, increment the state 1528 f11e ee 00 21 inc pausestate 1529 f121 1530 f121 ;silence volume at the start and end of pausing 1531 f121 a9 00 lda #0 1532 f123 85 19 sta AUDV0 1533 f125 85 1a sta AUDV1 1534 f127 1535 f127 - ifconst pokeysupport 1536 f127 - ldy #7 1537 f127 -pausesilencepokeyaudioloop 1538 f127 - sta (pokeybase),y 1539 f127 - dey 1540 f127 - bpl pausesilencepokeyaudioloop 1541 f127 endif ; pokeysupport 1542 f127 1543 f127 a9 ff lda #$ff 1544 f129 8d ac 01 sta pausebuttonflag 1545 f12c d0 0d bne carryonpausing 1546 f12e 1547 f12e enterpausestate2 1548 f12e a9 02 lda #2 1549 f130 8d 00 21 sta pausestate 1550 f133 d0 06 bne carryonpausing 1551 f135 leavepauseroutine 1552 f135 ad 07 21 lda sCTRL 1553 f138 85 3c sta CTRL 1554 f13a 60 rts 1555 f13b carryonpausing 1556 f13b - ifconst .pause 1557 f13b - jsr .pause 1558 f13b endif ; .pause 1559 f13b ad 07 21 lda sCTRL 1560 f13e 09 80 ora #%10000000 ; turn off colorburst during pause... 1561 f140 85 3c sta CTRL 1562 f142 4c e2 f0 jmp pauseroutine 1563 f145 endif ; pauseroutineoff 1564 f145 1565 f145 1566 f145 - ifconst DOUBLEBUFFER 1567 f145 -skipterminatedisplaylistreturn 1568 f145 - rts 1569 f145 endif ; DOUBLEBUFFER 1570 f145 terminatedisplaylist 1571 f145 - ifconst DOUBLEBUFFER 1572 f145 - lda doublebufferstate 1573 f145 - bne skipterminatedisplaylistreturn ; double-buffering runs it's own DL termination code 1574 f145 endif ; DOUBLEBUFFER 1575 f145 terminatedisplaybuffer 1576 f145 ;add DL end entry on each DL 1577 f145 a2 0b ldx #(WZONECOUNT-1) 1578 f147 dlendloop 1579 f147 bd e7 f5 lda DLPOINTL,x 1580 f14a - ifconst DOUBLEBUFFER 1581 f14a - clc 1582 f14a - adc doublebufferdloffset 1583 f14a endif ; DOUBLEBUFFER 1584 f14a 85 63 sta dlpnt 1585 f14c bd db f5 lda DLPOINTH,x 1586 f14f - ifconst DOUBLEBUFFER 1587 f14f - adc #0 1588 f14f endif ; DOUBLEBUFFER 1589 f14f 85 64 sta dlpnt+1 1590 f151 b4 65 ldy dlend,x 1591 f153 a9 00 lda #$00 1592 f155 dlendmoreloops 1593 f155 c8 iny 1594 f156 91 63 sta (dlpnt),y 1595 f158 - ifconst FRAMESKIPGLITCHFIXWEAK 1596 f158 - cpy #DLLASTOBJ+1 1597 f158 - beq dlendthiszonedone 1598 f158 - iny 1599 f158 - iny 1600 f158 - iny 1601 f158 - iny 1602 f158 - iny 1603 f158 - sta (dlpnt),y 1604 f158 -dlendthiszonedone 1605 f158 endif FRAMESKIPGLITCHFIXWEAK 1606 f158 - ifconst FRAMESKIPGLITCHFIX 1607 f158 - iny 1608 f158 - iny 1609 f158 - iny 1610 f158 - iny 1611 f158 - cpy #DLLASTOBJ-1 1612 f158 - bcc dlendmoreloops 1613 f158 endif ; FRAMESKIPGLITCHFIX 1614 f158 ca dex 1615 f159 10 ec bpl dlendloop 1616 f15b 1617 f15b ifnconst pauseroutineoff 1618 f15b 20 e2 f0 jsr pauseroutine 1619 f15e endif ; pauseroutineoff 1620 f15e 60 rts 1621 f15f 1622 f15f uninterruptableroutines 1623 f15f ; this is for routines that must happen off the visible screen, each frame. 1624 f15f 1625 f15f - ifconst AVOXVOICE 1626 f15f - jsr serviceatarivoxqueue 1627 f15f endif 1628 f15f 1629 f15f a9 00 lda #0 1630 f161 8d b6 01 sta palfastframe 1631 f164 ad 09 21 lda paldetected 1632 f167 f0 10 beq skippalframeadjusting 1633 f169 ; ** PAL console is detected. we increment palframes to accurately count 5 frames, 1634 f169 ae b5 01 ldx palframes 1635 f16c e8 inx 1636 f16d e0 05 cpx #5 1637 f16f d0 05 bne palframeskipdone 1638 f171 ee b6 01 inc palfastframe 1639 f174 a2 00 ldx #0 1640 f176 palframeskipdone 1641 f176 8e b5 01 stx palframes 1642 f179 skippalframeadjusting 1643 f179 1644 f179 - ifconst MUSICTRACKER 1645 f179 - ; We normally run the servicesong routine from the top-screen interrupt, but if it 1646 f179 - ; happens to interrupt the scheduling of a sound effect in the game code, we skip it. 1647 f179 - ; If that happens, we try again here. Chances are very small we'll run into the same 1648 f179 - ; problem twice, and if we do, we just drop a musical note or two. 1649 f179 - lda sfxschedulemissed 1650 f179 - beq servicesongwasnotmissed 1651 f179 - jsr servicesong 1652 f179 -servicesongwasnotmissed 1653 f179 endif ; MUSICTRACKER 1654 f179 1655 f179 60 rts 1656 f17a 1657 f17a serviceatarivoxqueue 1658 f17a - ifconst AVOXVOICE 1659 f17a - lda voxlock 1660 f17a - bne skipvoxprocessing ; the vox is in the middle of speech address update 1661 f17a -skipvoxqueuesizedec 1662 f17a - jmp processavoxvoice 1663 f17a -skipvoxprocessing 1664 f17a - rts 1665 f17a - 1666 f17a -processavoxvoice 1667 f17a - lda avoxenable 1668 f17a - bne avoxfixport 1669 f17a - SPKOUT tempavox 1670 f17a - rts 1671 f17a -avoxfixport 1672 f17a - lda #0 ; restore the port to all bits as inputs... 1673 f17a - sta CTLSWA 1674 f17a - rts 1675 f17a -silenceavoxvoice 1676 f17a - SPEAK avoxsilentdata 1677 f17a - rts 1678 f17a -avoxsilentdata 1679 f17a - .byte 31,255 1680 f17a else 1681 f17a 60 rts 1682 f17b endif ; AVOXVOICE 1683 f17b 1684 f17b joybuttonhandler 1685 f17b 8a txa 1686 f17c 0a asl 1687 f17d a8 tay 1688 f17e b9 08 00 lda INPT0,y 1689 f181 4a lsr 1690 f182 9d 02 21 sta sINPT1,x 1691 f185 b9 09 00 lda INPT1,y 1692 f188 29 80 and #%10000000 1693 f18a 1d 02 21 ora sINPT1,x 1694 f18d 9d 02 21 sta sINPT1,x 1695 f190 1696 f190 b5 0c lda INPT4,x 1697 f192 30 19 bmi .skip1bjoyfirecheck 1698 f194 ;one button joystick is down 1699 f194 49 80 eor #%10000000 1700 f196 9d 02 21 sta sINPT1,x 1701 f199 1702 f199 ad b1 01 lda joybuttonmode 1703 f19c 3d b0 f1 and twobuttonmask,x 1704 f19f f0 0c beq .skip1bjoyfirecheck 1705 f1a1 ad b1 01 lda joybuttonmode 1706 f1a4 1d b0 f1 ora twobuttonmask,x 1707 f1a7 8d b1 01 sta joybuttonmode 1708 f1aa 8d 82 02 sta SWCHB 1709 f1ad .skip1bjoyfirecheck 1710 f1ad 4c 5c f0 jmp buttonreadloopreturn 1711 f1b0 1712 f1b0 twobuttonmask 1713 f1b0 04 10 .byte.b %00000100,%00010000 1714 f1b2 1715 f1b2 gunbuttonhandler ; outside of the conditional, so our button handler LUT is valid 1716 f1b2 - ifconst LIGHTGUNSUPPORT 1717 f1b2 - cpx #0 1718 f1b2 - bne secondportgunhandler 1719 f1b2 -firstportgunhandler 1720 f1b2 - lda SWCHA 1721 f1b2 - asl 1722 f1b2 - asl 1723 f1b2 - asl ; shift D4 to D7 1724 f1b2 - and #%10000000 1725 f1b2 - eor #%10000000 1726 f1b2 - sta sINPT1 1727 f1b2 - jmp buttonreadloopreturn 1728 f1b2 -secondportgunhandler 1729 f1b2 - lda SWCHA 1730 f1b2 - lsr ; shift D0 into carry 1731 f1b2 - lsr ; shift carry into D7 1732 f1b2 - and #%10000000 1733 f1b2 - eor #%10000000 1734 f1b2 - sta sINPT3 1735 f1b2 - jmp buttonreadloopreturn 1736 f1b2 endif ; LIGHTGUNSUPPORT 1737 f1b2 1738 f1b2 controlsusing2buttoncode 1739 f1b2 00 .byte.b 0 ; 00=no controller plugged in 1740 f1b3 01 .byte.b 1 ; 01=proline joystick 1741 f1b4 00 .byte.b 0 ; 02=lightgun 1742 f1b5 00 .byte.b 0 ; 03=paddle 1743 f1b6 01 .byte.b 1 ; 04=trakball 1744 f1b7 01 .byte.b 1 ; 05=vcs joystick 1745 f1b8 01 .byte.b 1 ; 06=driving control 1746 f1b9 00 .byte.b 0 ; 07=keypad control 1747 f1ba 00 .byte.b 0 ; 08=st mouse/cx80 1748 f1bb 00 .byte.b 0 ; 09=amiga mouse 1749 f1bc 01 .byte.b 1 ; 10=atarivox 1750 f1bd 1751 f1bd buttonhandlerhi 1752 f1bd 00 .byte.b 0 ; 00=no controller plugged in 1753 f1be f1 .byte.b >joybuttonhandler ; 01=proline joystick 1754 f1bf f1 .byte.b >gunbuttonhandler ; 02=lightgun 1755 f1c0 f4 .byte.b >paddlebuttonhandler ; 03=paddle 1756 f1c1 f1 .byte.b >joybuttonhandler ; 04=trakball 1757 f1c2 f1 .byte.b >joybuttonhandler ; 05=vcs joystick 1758 f1c3 f1 .byte.b >joybuttonhandler ; 06=driving control 1759 f1c4 00 .byte.b 0 ; 07=keypad 1760 f1c5 f4 .byte.b >mousebuttonhandler ; 08=st mouse 1761 f1c6 f4 .byte.b >mousebuttonhandler ; 09=amiga mouse 1762 f1c7 f1 .byte.b >joybuttonhandler ; 10=atarivox 1763 f1c8 buttonhandlerlo 1764 f1c8 00 .byte.b 0 ; 00=no controller plugged in 1765 f1c9 7b .byte.b $0F means the sound is looped while priority is active 1866 f226 1867 f226 05 d9 ora inttemp2 1868 f228 05 d8 ora inttemp1 ; check if F|C|V=0 1869 f22a f0 23 beq zerosfx ; if so, we're at the end of the sound. 1870 f22c 1871 f22c advancesfxpointer 1872 f22c ; advance the pointer to the next sound chunk 1873 f22c c8 iny 1874 f22d 84 da sty inttemp3 1875 f22f 18 clc 1876 f230 b5 4e lda sfx1pointlo,x 1877 f232 65 da adc inttemp3 1878 f234 95 4e sta sfx1pointlo,x 1879 f236 b5 50 lda sfx1pointhi,x 1880 f238 69 00 adc #0 1881 f23a 95 50 sta sfx1pointhi,x 1882 f23c 4c e7 f1 jmp servicesfxchannelsloop 1883 f23f 1884 f23f sfxsoundloop 1885 f23f 48 pha 1886 f240 b5 52 lda sfx1priority,x 1887 f242 d0 04 bne sfxsoundloop_carryon 1888 f244 68 pla ; fix the stack before we go 1889 f245 4c 2c f2 jmp advancesfxpointer 1890 f248 sfxsoundloop_carryon 1891 f248 68 pla 1892 f249 29 f0 and #$F0 1893 f24b 4a lsr 1894 f24c 4a lsr 1895 f24d 4a lsr 1896 f24e 4a lsr 1897 f24f 1898 f24f zerosfx 1899 f24f 95 4e sta sfx1pointlo,x 1900 f251 95 50 sta sfx1pointhi,x 1901 f253 95 52 sta sfx1priority,x 1902 f255 4c e7 f1 jmp servicesfxchannelsloop 1903 f258 1904 f258 1905 f258 schedulesfx 1906 f258 ; called with sfxinstrumentlo=data sfxpitchoffset=pitch-offset sfxnoteindex=note index 1907 f258 a0 00 ldy #0 1908 f25a b1 e0 lda (sfxinstrumentlo),y 1909 f25c - ifconst pokeysupport 1910 f25c - cmp #$20 ; POKEY? 1911 f25c - bne scheduletiasfx 1912 f25c - jmp schedulepokeysfx 1913 f25c endif 1914 f25c scheduletiasfx 1915 f25c ;cmp #$10 ; TIA? 1916 f25c ;beq continuescheduletiasfx 1917 f25c ; rts ; unhandled!!! 1918 f25c continuescheduletiasfx 1919 f25c ifnconst TIASFXMONO 1920 f25c a5 4e lda sfx1pointlo 1921 f25e 05 50 ora sfx1pointhi 1922 f260 f0 13 beq schedulesfx1 ;if channel 1 is idle, use it 1923 f262 a5 4f lda sfx2pointlo 1924 f264 05 51 ora sfx2pointhi 1925 f266 f0 11 beq schedulesfx2 ;if channel 2 is idle, use it 1926 f268 ; Both channels are scheduled. 1927 f268 a0 01 ldy #1 1928 f26a b1 e0 lda (sfxinstrumentlo),y 1929 f26c d0 01 bne interruptsfx 1930 f26e 60 rts ; the new sound has 0 priority and both channels are busy. Skip playing it. 1931 f26f interruptsfx 1932 f26f ;Compare which active sound has a lower priority. We'll interrupt the lower one. 1933 f26f a5 52 lda sfx1priority 1934 f271 c5 53 cmp sfx2priority 1935 f273 b0 04 bcs schedulesfx2 1936 f275 endif ; !TIASFXMONO 1937 f275 1938 f275 schedulesfx1 1939 f275 a2 00 ldx #0 ; channel 1 1940 f277 ifnconst TIASFXMONO 1941 f277 f0 02 beq skipschedulesfx2 1942 f279 schedulesfx2 1943 f279 a2 01 ldx #1 ; channel 2 1944 f27b skipschedulesfx2 1945 f27b endif ; !TIASFXMONO 1946 f27b 1947 f27b - ifconst MUSICTRACKER 1948 f27b - lda sfxnoteindex 1949 f27b - bpl skipdrumkitoverride 1950 f27b - and #$7F ; subtract 128 1951 f27b - sec 1952 f27b - sbc #4 ; drums start at 132, i.e. octave 10 1953 f27b - asl 1954 f27b - tay 1955 f27b - lda tiadrumkitdefinition,y 1956 f27b - sta sfxinstrumentlo 1957 f27b - iny 1958 f27b - lda tiadrumkitdefinition,y 1959 f27b - sta sfxinstrumenthi 1960 f27b - lda #0 1961 f27b - sta sfxnoteindex ; and tell the driver it's a non-pitched instrument 1962 f27b -skipdrumkitoverride 1963 f27b endif ; MUSICTRACKER 1964 f27b a0 01 ldy #1 ; get priority and sound-resolution (in frames) 1965 f27d b1 e0 lda (sfxinstrumentlo),y 1966 f27f 95 52 sta sfx1priority,x 1967 f281 c8 iny 1968 f282 b1 e0 lda (sfxinstrumentlo),y 1969 f284 95 56 sta sfx1frames,x 1970 f286 a5 e0 lda sfxinstrumentlo 1971 f288 18 clc 1972 f289 69 03 adc #3 1973 f28b 95 4e sta sfx1pointlo,x 1974 f28d a5 e1 lda sfxinstrumenthi 1975 f28f 69 00 adc #0 1976 f291 95 50 sta sfx1pointhi,x 1977 f293 a5 e2 lda sfxpitchoffset 1978 f295 95 54 sta sfx1poffset,x 1979 f297 a9 00 lda #0 1980 f299 95 58 sta sfx1tick,x 1981 f29b a5 e3 lda sfxnoteindex 1982 f29d 95 cd sta sfx1notedata,x 1983 f29f 60 rts 1984 f2a0 1985 f2a0 plotsprite 1986 f2a0 ifnconst NODRAWWAIT 1987 f2a0 - ifconst DOUBLEBUFFER 1988 f2a0 - lda doublebufferstate 1989 f2a0 - bne skipplotspritewait 1990 f2a0 endif ; DOUBLEBUFFER 1991 f2a0 - ifconst DEBUGWAITCOLOR 1992 f2a0 - lda #$41 1993 f2a0 - sta BACKGRND 1994 f2a0 endif 1995 f2a0 plotspritewait 1996 f2a0 a5 4d lda visibleover 1997 f2a2 d0 fc bne plotspritewait 1998 f2a4 skipplotspritewait 1999 f2a4 - ifconst DEBUGWAITCOLOR 2000 f2a4 - lda #$0 2001 f2a4 - sta BACKGRND 2002 f2a4 endif 2003 f2a4 endif 2004 f2a4 2005 f2a4 ;arguments: 2006 f2a4 ; temp1=lo graphicdata 2007 f2a4 ; temp2=hi graphicdata 2008 f2a4 ; temp3=palette | width byte 2009 f2a4 ; temp4=x 2010 f2a4 ; temp5=y 2011 f2a4 ; temp6=mode 2012 f2a4 a5 46 lda temp5 ;Y position 2013 f2a6 4a lsr ; 2 - Divide by 8 or 16 2014 f2a7 4a lsr ; 2 2015 f2a8 4a lsr ; 2 2016 f2a9 if WZONEHEIGHT = 16 2017 f2a9 4a lsr ; 2 2018 f2aa endif 2019 f2aa 2020 f2aa aa tax 2021 f2ab 2022 f2ab ifnconst NOLIMITCHECKING 2023 f2ab 2024 f2ab ; the next block allows for vertical masking, and ensures we don't overwrite non-DL memory 2025 f2ab 2026 f2ab c9 0c cmp #WZONECOUNT 2027 f2ad 2028 f2ad 90 0a bcc continueplotsprite1 ; the sprite is fully on-screen, so carry on... 2029 f2af ; otherwise, check to see if the bottom half is in zone 0... 2030 f2af 2031 f2af if WZONEHEIGHT = 16 2032 f2af c9 0f cmp #15 2033 f2b1 - else 2034 f2b1 - cmp #31 2035 f2b1 endif 2036 f2b1 2037 f2b1 d0 05 bne exitplotsprite1 2038 f2b3 a2 00 ldx #0 2039 f2b5 4c ee f2 jmp continueplotsprite2 2040 f2b8 exitplotsprite1 2041 f2b8 60 rts 2042 f2b9 2043 f2b9 continueplotsprite1 2044 f2b9 endif 2045 f2b9 2046 f2b9 bd e7 f5 lda DLPOINTL,x ;Get pointer to DL that this sprite starts in 2047 f2bc - ifconst DOUBLEBUFFER 2048 f2bc - clc 2049 f2bc - adc doublebufferdloffset 2050 f2bc endif ; DOUBLEBUFFER 2051 f2bc 85 63 sta dlpnt 2052 f2be bd db f5 lda DLPOINTH,x 2053 f2c1 - ifconst DOUBLEBUFFER 2054 f2c1 - adc #0 2055 f2c1 endif ; DOUBLEBUFFER 2056 f2c1 85 64 sta dlpnt+1 2057 f2c3 2058 f2c3 ;Create DL entry for upper part of sprite 2059 f2c3 2060 f2c3 b4 65 ldy dlend,x ;Get the index to the end of this DL 2061 f2c5 2062 f2c5 - ifconst CHECKOVERWRITE 2063 f2c5 - cpy #DLLASTOBJ 2064 f2c5 - beq checkcontinueplotsprite2 2065 f2c5 -continueplotsprite1a 2066 f2c5 endif 2067 f2c5 2068 f2c5 a5 42 lda temp1 ; graphic data, lo byte 2069 f2c7 91 63 sta (dlpnt),y ;Low byte of data address 2070 f2c9 2071 f2c9 ifnconst ATOMICSPRITEUPDATE 2072 f2c9 c8 iny 2073 f2ca a5 47 lda temp6 2074 f2cc 91 63 sta (dlpnt),y 2075 f2ce - else 2076 f2ce - iny 2077 f2ce - sty temp8 2078 f2ce endif 2079 f2ce 2080 f2ce c8 iny 2081 f2cf 2082 f2cf a5 46 lda temp5 ;Y position 2083 f2d1 29 0f and #(WZONEHEIGHT - 1) 2084 f2d3 c9 01 cmp #1 ; clear carry if our sprite is just in this zone 2085 f2d5 05 43 ora temp2 ; graphic data, hi byte 2086 f2d7 91 63 sta (dlpnt),y 2087 f2d9 2088 f2d9 2089 f2d9 c8 iny 2090 f2da a5 44 lda temp3 ;palette|width 2091 f2dc 91 63 sta (dlpnt),y 2092 f2de 2093 f2de c8 iny 2094 f2df a5 45 lda temp4 ;Horizontal position 2095 f2e1 91 63 sta (dlpnt),y 2096 f2e3 2097 f2e3 c8 iny 2098 f2e4 94 65 sty dlend,x 2099 f2e6 2100 f2e6 - ifconst ALWAYSTERMINATE 2101 f2e6 - iny 2102 f2e6 - lda #0 2103 f2e6 - sta (dlpnt),y 2104 f2e6 endif 2105 f2e6 2106 f2e6 - ifconst ATOMICSPRITEUPDATE 2107 f2e6 - ldy temp8 2108 f2e6 - lda temp6 2109 f2e6 - sta (dlpnt),y 2110 f2e6 endif 2111 f2e6 2112 f2e6 checkcontinueplotsprite2 2113 f2e6 2114 f2e6 90 33 bcc doneSPDL ;branch if the sprite was fully in the last zone 2115 f2e8 2116 f2e8 ;Create DL entry for lower part of sprite 2117 f2e8 2118 f2e8 e8 inx ;Next region 2119 f2e9 2120 f2e9 ifnconst NOLIMITCHECKING 2121 f2e9 e0 0c cpx #WZONECOUNT 2122 f2eb 2123 f2eb 90 01 bcc continueplotsprite2 ; the second half of the sprite is fully on-screen, so carry on... 2124 f2ed 60 rts 2125 f2ee continueplotsprite2 2126 f2ee endif 2127 f2ee 2128 f2ee bd e7 f5 lda DLPOINTL,x ;Get pointer to next DL 2129 f2f1 - ifconst DOUBLEBUFFER 2130 f2f1 - clc 2131 f2f1 - adc doublebufferdloffset 2132 f2f1 endif ; DOUBLEBUFFER 2133 f2f1 85 63 sta dlpnt 2134 f2f3 bd db f5 lda DLPOINTH,x 2135 f2f6 - ifconst DOUBLEBUFFER 2136 f2f6 - adc #0 2137 f2f6 endif ; DOUBLEBUFFER 2138 f2f6 85 64 sta dlpnt+1 2139 f2f8 b4 65 ldy dlend,x ;Get the index to the end of this DL 2140 f2fa 2141 f2fa - ifconst CHECKOVERWRITE 2142 f2fa - cpy #DLLASTOBJ 2143 f2fa - bne continueplotsprite2a 2144 f2fa - rts 2145 f2fa -continueplotsprite2a 2146 f2fa endif 2147 f2fa 2148 f2fa a5 42 lda temp1 ; graphic data, lo byte 2149 f2fc 91 63 sta (dlpnt),y 2150 f2fe 2151 f2fe ifnconst ATOMICSPRITEUPDATE 2152 f2fe c8 iny 2153 f2ff a5 47 lda temp6 2154 f301 91 63 sta (dlpnt),y 2155 f303 - else 2156 f303 - iny 2157 f303 - sty temp8 2158 f303 endif 2159 f303 2160 f303 c8 iny 2161 f304 2162 f304 a5 46 lda temp5 ;Y position 2163 f306 0b 0f anc #(WZONEHEIGHT - 1) ; undocumented. A=A&IMM, then move bit 7 into carry 2164 f308 05 43 ora temp2 ; graphic data, hi byte 2165 f30a e9 0f sbc #(WZONEHEIGHT-1) ; start at the DMA hole. -1 because carry is clear 2166 f30c 91 63 sta (dlpnt),y 2167 f30e 2168 f30e c8 iny 2169 f30f 2170 f30f a5 44 lda temp3 ;palette|width 2171 f311 91 63 sta (dlpnt),y 2172 f313 2173 f313 c8 iny 2174 f314 2175 f314 a5 45 lda temp4 ;Horizontal position 2176 f316 91 63 sta (dlpnt),y 2177 f318 2178 f318 c8 iny 2179 f319 94 65 sty dlend,x 2180 f31b 2181 f31b - ifconst ALWAYSTERMINATE 2182 f31b - iny 2183 f31b - lda #0 2184 f31b - sta (dlpnt),y 2185 f31b endif 2186 f31b 2187 f31b - ifconst ATOMICSPRITEUPDATE 2188 f31b - ldy temp8 2189 f31b - lda temp6 2190 f31b - sta (dlpnt),y 2191 f31b endif 2192 f31b 2193 f31b doneSPDL 2194 f31b 60 rts 2195 f31c 2196 f31c 2197 f31c lockzonex 2198 f31c - ifconst ZONELOCKS 2199 f31c - ldy dlend,x 2200 f31c - cpy #DLLASTOBJ 2201 f31c - beq lockzonexreturn ; the zone is either stuffed or locked. abort! 2202 f31c - lda DLPOINTL,x 2203 f31c - ifconst DOUBLEBUFFER 2204 f31c - clc 2205 f31c - adc doublebufferdloffset 2206 f31c - endif ; DOUBLEBUFFER 2207 f31c - sta dlpnt 2208 f31c - lda DLPOINTH,x 2209 f31c - ifconst DOUBLEBUFFER 2210 f31c - adc #0 2211 f31c - endif ; DOUBLEBUFFER 2212 f31c - sta dlpnt+1 2213 f31c - iny 2214 f31c - lda #0 2215 f31c - sta (dlpnt),y 2216 f31c - dey 2217 f31c - tya 2218 f31c - ldy #(DLLASTOBJ-1) 2219 f31c - sta (dlpnt),y 2220 f31c - iny 2221 f31c - sty dlend,x 2222 f31c -lockzonexreturn 2223 f31c - rts 2224 f31c endif ; ZONELOCKS 2225 f31c unlockzonex 2226 f31c - ifconst ZONELOCKS 2227 f31c - ldy dlend,x 2228 f31c - cpy #DLLASTOBJ 2229 f31c - bne unlockzonexreturn ; if the zone isn't stuffed, it's not locked. abort! 2230 f31c - lda DLPOINTL,x 2231 f31c - ifconst DOUBLEBUFFER 2232 f31c - clc 2233 f31c - adc doublebufferdloffset 2234 f31c - endif ; DOUBLEBUFFER 2235 f31c - sta dlpnt 2236 f31c - lda DLPOINTH,x 2237 f31c - ifconst DOUBLEBUFFER 2238 f31c - adc #0 2239 f31c - endif ; DOUBLEBUFFER 2240 f31c - sta dlpnt+1 2241 f31c - dey 2242 f31c - ;ldy #(DLLASTOBJ-1) 2243 f31c - lda (dlpnt),y 2244 f31c - tay 2245 f31c - sty dlend,x 2246 f31c -unlockzonexreturn 2247 f31c endif ; ZONELOCKS 2248 f31c 60 rts 2249 f31d 2250 f31d plotcharloop 2251 f31d ; ** read from a data indirectly pointed to from temp8,temp9 2252 f31d ; ** format is: lo_data, hi_data, palette|width, x, y 2253 f31d ; ** format ends with lo_data | hi_data = 0 2254 f31d 2255 f31d - ifconst DOUBLEBUFFER 2256 f31d - lda doublebufferstate 2257 f31d - bne skipplotcharloopwait 2258 f31d endif ; DOUBLEBUFFER 2259 f31d - ifconst DEBUGWAITCOLOR 2260 f31d - lda #$61 2261 f31d - sta BACKGRND 2262 f31d endif 2263 f31d plotcharloopwait 2264 f31d a5 4d lda visibleover 2265 f31f d0 fc bne plotcharloopwait 2266 f321 - ifconst DEBUGWAITCOLOR 2267 f321 - lda #0 2268 f321 - sta BACKGRND 2269 f321 endif 2270 f321 skipplotcharloopwait 2271 f321 plotcharlooploop 2272 f321 a0 00 ldy #0 2273 f323 b1 49 lda (temp8),y 2274 f325 85 42 sta temp1 2275 f327 c8 iny 2276 f328 b1 49 lda (temp8),y 2277 f32a 85 43 sta temp2 2278 f32c 05 42 ora temp1 2279 f32e d0 01 bne plotcharloopcontinue 2280 f330 ;the pointer=0, so return 2281 f330 60 rts 2282 f331 plotcharloopcontinue 2283 f331 c8 iny 2284 f332 b1 49 lda (temp8),y 2285 f334 85 44 sta temp3 2286 f336 c8 iny 2287 f337 b1 49 lda (temp8),y 2288 f339 85 45 sta temp4 2289 f33b c8 iny 2290 f33c b1 49 lda (temp8),y 2291 f33e ;sta temp5 ; not needed with our late entry. 2292 f33e 20 57 f3 jsr plotcharactersskipentry 2293 f341 a5 49 lda temp8 2294 f343 18 clc 2295 f344 69 05 adc #5 2296 f346 85 49 sta temp8 2297 f348 a5 4a lda temp9 2298 f34a 69 00 adc #0 2299 f34c 85 4a sta temp9 2300 f34e 4c 21 f3 jmp plotcharlooploop 2301 f351 2302 f351 plotcharacters 2303 f351 - ifconst DOUBLEBUFFER 2304 f351 - lda doublebufferstate 2305 f351 - bne skipplotcharacterswait 2306 f351 endif ; DOUBLEBUFFER 2307 f351 - ifconst DEBUGWAITCOLOR 2308 f351 - lda #$41 2309 f351 - sta BACKGRND 2310 f351 endif 2311 f351 plotcharacterswait 2312 f351 a5 4d lda visibleover 2313 f353 d0 fc bne plotcharacterswait 2314 f355 - ifconst DEBUGWAITCOLOR 2315 f355 - sta BACKGRND 2316 f355 endif 2317 f355 skipplotcharacterswait 2318 f355 ;arguments: 2319 f355 ; temp1=lo charactermap 2320 f355 ; temp2=hi charactermap 2321 f355 ; temp3=palette | width byte 2322 f355 ; temp4=x 2323 f355 ; temp5=y 2324 f355 2325 f355 a5 46 lda temp5 ;Y position 2326 f357 2327 f357 plotcharactersskipentry 2328 f357 2329 f357 ;ifconst ZONEHEIGHT 2330 f357 ; if ZONEHEIGHT = 16 2331 f357 ; and #$0F 2332 f357 ; endif 2333 f357 ; if ZONEHEIGHT = 8 2334 f357 ; and #$1F 2335 f357 ; endif 2336 f357 ;else 2337 f357 ; and #$0F 2338 f357 ;endif 2339 f357 2340 f357 aa tax 2341 f358 bd e7 f5 lda DLPOINTL,x ;Get pointer to DL that the characters are in 2342 f35b - ifconst DOUBLEBUFFER 2343 f35b - clc 2344 f35b - adc doublebufferdloffset 2345 f35b endif ; DOUBLEBUFFER 2346 f35b 85 63 sta dlpnt 2347 f35d bd db f5 lda DLPOINTH,x 2348 f360 - ifconst DOUBLEBUFFER 2349 f360 - adc #0 2350 f360 endif ; DOUBLEBUFFER 2351 f360 85 64 sta dlpnt+1 2352 f362 2353 f362 ;Create DL entry for the characters 2354 f362 2355 f362 b4 65 ldy dlend,x ;Get the index to the end of this DL 2356 f364 2357 f364 - ifconst CHECKOVERWRITE 2358 f364 - cpy #DLLASTOBJ 2359 f364 - bne continueplotcharacters 2360 f364 - rts 2361 f364 -continueplotcharacters 2362 f364 endif 2363 f364 2364 f364 a5 42 lda temp1 ; character map data, lo byte 2365 f366 91 63 sta (dlpnt),y ;(1) store low address 2366 f368 2367 f368 c8 iny 2368 f369 ad 06 21 lda charactermode 2369 f36c 91 63 sta (dlpnt),y ;(2) store mode 2370 f36e 2371 f36e c8 iny 2372 f36f a5 43 lda temp2 ; character map, hi byte 2373 f371 91 63 sta (dlpnt),y ;(3) store high address 2374 f373 2375 f373 c8 iny 2376 f374 a5 44 lda temp3 ;palette|width 2377 f376 91 63 sta (dlpnt),y ;(4) store palette|width 2378 f378 2379 f378 c8 iny 2380 f379 a5 45 lda temp4 ;Horizontal position 2381 f37b 91 63 sta (dlpnt),y ;(5) store horizontal position 2382 f37d 2383 f37d c8 iny 2384 f37e 94 65 sty dlend,x ; save display list end byte 2385 f380 60 rts 2386 f381 2387 f381 2388 f381 - ifconst plotvalueonscreen 2389 f381 -plotcharacterslive 2390 f381 - ; a version of plotcharacters that draws live and minimally disrupts the screen... 2391 f381 - 2392 f381 - ;arguments: 2393 f381 - ; temp1=lo charactermap 2394 f381 - ; temp2=hi charactermap 2395 f381 - ; temp3=palette | width byte 2396 f381 - ; temp4=x 2397 f381 - ; temp5=y 2398 f381 - 2399 f381 - lda temp5 ;Y position 2400 f381 - 2401 f381 - tax 2402 f381 - lda DLPOINTL,x ;Get pointer to DL that the characters are in 2403 f381 - ifconst DOUBLEBUFFER 2404 f381 - clc 2405 f381 - adc doublebufferdloffset 2406 f381 - endif ; DOUBLEBUFFER 2407 f381 - sta dlpnt 2408 f381 - lda DLPOINTH,x 2409 f381 - ifconst DOUBLEBUFFER 2410 f381 - adc #0 2411 f381 - endif ; DOUBLEBUFFER 2412 f381 - sta dlpnt+1 2413 f381 - 2414 f381 - ;Create DL entry for the characters 2415 f381 - 2416 f381 - ldy dlend,x ;Get the index to the end of this DL 2417 f381 - 2418 f381 - ifconst CHECKOVERWRITE 2419 f381 - cpy #DLLASTOBJ 2420 f381 - bne continueplotcharacterslive 2421 f381 - rts 2422 f381 -continueplotcharacterslive 2423 f381 - endif 2424 f381 - 2425 f381 - lda temp1 ; character map data, lo byte 2426 f381 - sta (dlpnt),y ;(1) store low address 2427 f381 - 2428 f381 - iny 2429 f381 - ; we don't add the second byte yet, since the charmap could briefly 2430 f381 - ; render without a proper character map address, width, or position. 2431 f381 - lda charactermode 2432 f381 - sta (dlpnt),y ;(2) store mode 2433 f381 - 2434 f381 - iny 2435 f381 - lda temp2 ; character map, hi byte 2436 f381 - sta (dlpnt),y ;(3) store high address 2437 f381 - 2438 f381 - iny 2439 f381 - lda temp3 ;palette|width 2440 f381 - sta (dlpnt),y ;(4) store palette|width 2441 f381 - 2442 f381 - iny 2443 f381 - lda temp4 ;Horizontal position 2444 f381 - sta (dlpnt),y ;(5) store horizontal position 2445 f381 - 2446 f381 - iny 2447 f381 - sty dlend,x ; save display list end byte 2448 f381 - 2449 f381 - rts 2450 f381 endif ;plotcharacterslive 2451 f381 2452 f381 - ifconst USED_PLOTVALUE 2453 f381 -plotvalue 2454 f381 - ; calling 7800basic command: 2455 f381 - ; plotvalue digit_gfx palette variable/data number_of_digits screen_x screen_y 2456 f381 - ; ...displays the variable as BCD digits 2457 f381 - ; 2458 f381 - ; asm sub arguments: 2459 f381 - ; temp1=lo charactermap 2460 f381 - ; temp2=hi charactermap 2461 f381 - ; temp3=palette | width byte 2462 f381 - ; temp4=x 2463 f381 - ; temp5=y 2464 f381 - ; temp6=number of digits 2465 f381 - ; temp7=lo variable 2466 f381 - ; temp8=hi variable 2467 f381 - ; temp9=character mode 2468 f381 - 2469 f381 -plotdigitcount = temp6 2470 f381 - 2471 f381 - ifconst ZONELOCKS 2472 f381 - ldx temp5 2473 f381 - ldy dlend,x 2474 f381 - cpy #DLLASTOBJ 2475 f381 - bne carryonplotvalue 2476 f381 - rts 2477 f381 -carryonplotvalue 2478 f381 - endif 2479 f381 - 2480 f381 - lda #0 2481 f381 - tay 2482 f381 - ldx valbufend 2483 f381 - 2484 f381 - lda plotdigitcount 2485 f381 - and #1 2486 f381 - beq pvnibble2char 2487 f381 - lda #0 2488 f381 - sta VALBUFFER,x ; just in case we skip this digit 2489 f381 - beq pvnibble2char_skipnibble 2490 f381 - 2491 f381 -pvnibble2char 2492 f381 - ; high nibble... 2493 f381 - lda (temp7),y 2494 f381 - and #$f0 2495 f381 - lsr 2496 f381 - lsr 2497 f381 - lsr 2498 f381 - ifnconst DOUBLEWIDE ; multiply value by 2 for double-width 2499 f381 - lsr 2500 f381 - endif 2501 f381 - 2502 f381 - clc 2503 f381 - adc temp1 ; add the offset to character graphics to our value 2504 f381 - sta VALBUFFER,x 2505 f381 - inx 2506 f381 - dec plotdigitcount 2507 f381 - 2508 f381 -pvnibble2char_skipnibble 2509 f381 - ; low nibble... 2510 f381 - lda (temp7),y 2511 f381 - and #$0f 2512 f381 - ifconst DOUBLEWIDE ; multiply value by 2 for double-width 2513 f381 - asl 2514 f381 - endif 2515 f381 - clc 2516 f381 - adc temp1 ; add the offset to character graphics to our value 2517 f381 - sta VALBUFFER,x 2518 f381 - inx 2519 f381 - iny 2520 f381 - 2521 f381 - dec plotdigitcount 2522 f381 - bne pvnibble2char 2523 f381 - 2524 f381 - ;point to the start of our valuebuffer 2525 f381 - clc 2526 f381 - lda #VALBUFFER 2530 f381 - adc #0 2531 f381 - sta temp2 2532 f381 - 2533 f381 - ;advance valbufend to the end of our value buffer 2534 f381 - stx valbufend 2535 f381 - 2536 f381 - ifnconst plotvalueonscreen 2537 f381 - jmp plotcharacters 2538 f381 - else 2539 f381 - jmp plotcharacterslive 2540 f381 - endif 2541 f381 - 2542 f381 endif ; USED_PLOTVALUE 2543 f381 2544 f381 2545 f381 - ifconst USED_PLOTVALUEEXTRA 2546 f381 -plotdigitcount = temp6 2547 f381 -plotvalueextra 2548 f381 - ; calling 7800basic command: 2549 f381 - ; plotvalue digit_gfx palette variable/data number_of_digits screen_x screen_y 2550 f381 - ; ...displays the variable as BCD digits 2551 f381 - ; 2552 f381 - ; asm sub arguments: 2553 f381 - ; temp1=lo charactermap 2554 f381 - ; temp2=hi charactermap 2555 f381 - ; temp3=palette | width byte 2556 f381 - ; temp4=x 2557 f381 - ; temp5=y 2558 f381 - ; temp6=number of digits 2559 f381 - ; temp7=lo variable 2560 f381 - ; temp8=hi variable 2561 f381 - 2562 f381 - lda #0 2563 f381 - tay 2564 f381 - ldx valbufend 2565 f381 - ifnconst plotvalueonscreen 2566 f381 - sta VALBUFFER,x 2567 f381 - endif 2568 f381 - 2569 f381 - lda plotdigitcount 2570 f381 - and #1 2571 f381 - 2572 f381 - bne pvnibble2char_skipnibbleextra 2573 f381 - 2574 f381 -pvnibble2charextra 2575 f381 - ; high nibble... 2576 f381 - lda (temp7),y 2577 f381 - and #$f0 2578 f381 - lsr 2579 f381 - lsr 2580 f381 - ifnconst DOUBLEWIDE ; multiply value by 2 for double-width 2581 f381 - lsr 2582 f381 - endif 2583 f381 - clc 2584 f381 - adc temp1 ; add the offset to character graphics to our value 2585 f381 - sta VALBUFFER,x 2586 f381 - inx 2587 f381 - 2588 f381 - ; second half of the digit 2589 f381 - clc 2590 f381 - adc #1 2591 f381 - sta VALBUFFER,x 2592 f381 - inx 2593 f381 - 2594 f381 -pvnibble2char_skipnibbleextra 2595 f381 - ; low nibble... 2596 f381 - lda (temp7),y 2597 f381 - and #$0f 2598 f381 - ifconst DOUBLEWIDE ; multiply value by 2 for double-width 2599 f381 - asl 2600 f381 - endif 2601 f381 - asl 2602 f381 - 2603 f381 - clc 2604 f381 - adc temp1 ; add the offset to character graphics to our value 2605 f381 - sta VALBUFFER,x 2606 f381 - inx 2607 f381 - 2608 f381 - clc 2609 f381 - adc #1 2610 f381 - sta VALBUFFER,x 2611 f381 - inx 2612 f381 - iny 2613 f381 - 2614 f381 - dec plotdigitcount 2615 f381 - bne pvnibble2charextra 2616 f381 - 2617 f381 - ;point to the start of our valuebuffer 2618 f381 - clc 2619 f381 - lda #VALBUFFER 2623 f381 - adc #0 2624 f381 - sta temp2 2625 f381 - 2626 f381 - ;advance valbufend to the end of our value buffer 2627 f381 - stx valbufend 2628 f381 - 2629 f381 - ifnconst plotvalueonscreen 2630 f381 - jmp plotcharacters 2631 f381 - else 2632 f381 - jmp plotcharacterslive 2633 f381 - endif 2634 f381 endif ; USED_PLOTVALUEEXTRA 2635 f381 2636 f381 boxcollision 2637 f381 ; the worst case cycle-time for the code below is 43 cycles. 2638 f381 ; unfortunately, prior to getting here we've burned 44 cycles in argument setup. eep! 2639 f381 2640 f381 ;__boxx1 = accumulator 2641 f381 ;__boxy1 = y 2642 f381 00 44 __boxw1 = temp3 2643 f381 00 45 __boxh1 = temp4 2644 f381 2645 f381 00 46 __boxx2 = temp5 2646 f381 00 47 __boxy2 = temp6 2647 f381 00 48 __boxw2 = temp7 2648 f381 00 49 __boxh2 = temp8 2649 f381 2650 f381 DoXCollisionCheck 2651 f381 ;lda __boxx1 ; skipped. already in the accumulator 2652 f381 c5 46 cmp __boxx2 ;3 2653 f383 b0 07 bcs X1isbiggerthanX2 ;2/3 2654 f385 X2isbiggerthanX1 2655 f385 ; carry is clear 2656 f385 65 44 adc __boxw1 ;3 2657 f387 c5 46 cmp __boxx2 ;3 2658 f389 b0 08 bcs DoYCollisionCheck ;3/2 2659 f38b 60 rts ;6 - carry clear, no collision 2660 f38c X1isbiggerthanX2 2661 f38c 18 clc ;2 2662 f38d e5 48 sbc __boxw2 ;3 2663 f38f c5 46 cmp __boxx2 ;3 2664 f391 b0 13 bcs noboxcollision ;3/2 2665 f393 DoYCollisionCheck 2666 f393 98 tya ; 2 ; use to be "lda __boxy1" 2667 f394 c5 47 cmp __boxy2 ;3 2668 f396 b0 05 bcs Y1isbiggerthanY2 ;3/2 2669 f398 Y2isbiggerthanY1 2670 f398 ; carry is clear 2671 f398 65 45 adc __boxh1 ;3 2672 f39a c5 47 cmp __boxy2 ;3 2673 f39c 60 rts ;6 2674 f39d Y1isbiggerthanY2 2675 f39d 18 clc ;2 2676 f39e e5 49 sbc __boxh2 ;3 2677 f3a0 c5 47 cmp __boxy2 ;3 2678 f3a2 b0 02 bcs noboxcollision ;3/2 2679 f3a4 yesboxcollision 2680 f3a4 38 sec ;2 2681 f3a5 60 rts ;6 2682 f3a6 noboxcollision 2683 f3a6 18 clc ;2 2684 f3a7 60 rts ;6 2685 f3a8 2686 f3a8 randomize 2687 f3a8 a5 40 lda rand 2688 f3aa 4a lsr 2689 f3ab 26 41 rol rand16 2690 f3ad 90 02 bcc noeor 2691 f3af 49 b4 eor #$B4 2692 f3b1 noeor 2693 f3b1 85 40 sta rand 2694 f3b3 45 41 eor rand16 2695 f3b5 60 rts 2696 f3b6 2697 f3b6 ; *** bcd conversion routine courtesy Omegamatrix 2698 f3b6 ; *** http://atariage.com/forums/blog/563/entry-10832-hex-to-bcd-conversion-0-99/ 2699 f3b6 converttobcd 2700 f3b6 ;value to convert is in the accumulator 2701 f3b6 85 42 sta temp1 2702 f3b8 4a lsr 2703 f3b9 65 42 adc temp1 2704 f3bb 6a ror 2705 f3bc 4a lsr 2706 f3bd 4a lsr 2707 f3be 65 42 adc temp1 2708 f3c0 6a ror 2709 f3c1 65 42 adc temp1 2710 f3c3 6a ror 2711 f3c4 4a lsr 2712 f3c5 29 3c and #$3C 2713 f3c7 85 43 sta temp2 2714 f3c9 4a lsr 2715 f3ca 65 43 adc temp2 2716 f3cc 65 42 adc temp1 2717 f3ce 60 rts ; return the result in the accumulator 2718 f3cf 2719 f3cf ; Y and A contain multiplicands, result in A 2720 f3cf mul8 2721 f3cf 84 42 sty temp1 2722 f3d1 85 43 sta temp2 2723 f3d3 a9 00 lda #0 2724 f3d5 reptmul8 2725 f3d5 46 43 lsr temp2 2726 f3d7 90 03 bcc skipmul8 2727 f3d9 18 clc 2728 f3da 65 42 adc temp1 2729 f3dc ;bcs donemul8 might save cycles? 2730 f3dc skipmul8 2731 f3dc ;beq donemul8 might save cycles? 2732 f3dc 06 42 asl temp1 2733 f3de d0 f5 bne reptmul8 2734 f3e0 donemul8 2735 f3e0 60 rts 2736 f3e1 2737 f3e1 div8 2738 f3e1 ; A=numerator Y=denominator, result in A 2739 f3e1 c0 02 cpy #2 2740 f3e3 90 0a bcc div8end+1 ;div by 0 = bad, div by 1=no calc needed, so bail out 2741 f3e5 84 42 sty temp1 2742 f3e7 a0 ff ldy #$ff 2743 f3e9 div8loop 2744 f3e9 e5 42 sbc temp1 2745 f3eb c8 iny 2746 f3ec b0 fb bcs div8loop 2747 f3ee div8end 2748 f3ee 98 tya 2749 f3ef ; result in A 2750 f3ef 60 rts 2751 f3f0 2752 f3f0 ; Y and A contain multiplicands, result in temp2,A=low, temp1=high 2753 f3f0 mul16 2754 f3f0 84 42 sty temp1 2755 f3f2 85 43 sta temp2 2756 f3f4 2757 f3f4 a9 00 lda #0 2758 f3f6 a2 08 ldx #8 2759 f3f8 46 42 lsr temp1 2760 f3fa mul16_1 2761 f3fa 90 03 bcc mul16_2 2762 f3fc 18 clc 2763 f3fd 65 43 adc temp2 2764 f3ff mul16_2 2765 f3ff 6a ror 2766 f400 66 42 ror temp1 2767 f402 ca dex 2768 f403 d0 f5 bne mul16_1 2769 f405 85 43 sta temp2 2770 f407 60 rts 2771 f408 2772 f408 ; div int/int 2773 f408 ; numerator in A, denom in temp1 2774 f408 ; returns with quotient in A, remainder in temp1 2775 f408 div16 2776 f408 85 43 sta temp2 2777 f40a 84 42 sty temp1 2778 f40c a9 00 lda #0 2779 f40e a2 08 ldx #8 2780 f410 06 43 asl temp2 2781 f412 div16_1 2782 f412 2a rol 2783 f413 c5 42 cmp temp1 2784 f415 90 02 bcc div16_2 2785 f417 e5 42 sbc temp1 2786 f419 div16_2 2787 f419 26 43 rol temp2 2788 f41b ca dex 2789 f41c d0 f4 bne div16_1 2790 f41e 85 42 sta temp1 2791 f420 a5 43 lda temp2 2792 f422 60 rts 2793 f423 2794 f423 - ifconst bankswitchmode 2795 f423 -BS_jsr 2796 f423 - ifconst MCPDEVCART 2797 f423 - ora #$18 2798 f423 - sta $3000 2799 f423 - else 2800 f423 - sta $8000 2801 f423 - endif 2802 f423 - pla 2803 f423 - tax 2804 f423 - pla 2805 f423 - rts 2806 f423 - 2807 f423 -BS_return 2808 f423 - pla ; bankswitch bank 2809 f423 - ifconst BANKRAM 2810 f423 - sta currentbank 2811 f423 - ora currentrambank 2812 f423 - endif 2813 f423 - ifconst MCPDEVCART 2814 f423 - ora #$18 2815 f423 - sta $3000 2816 f423 - else 2817 f423 - sta $8000 2818 f423 - endif 2819 f423 - pla ; bankswitch $0 flag 2820 f423 - rts 2821 f423 endif 2822 f423 2823 f423 checkselectswitch 2824 f423 ad 82 02 lda SWCHB ; first check the real select switch... 2825 f426 29 02 and #%00000010 2826 f428 ifnconst MOUSESUPPORT 2827 f428 f0 05 beq checkselectswitchreturn ; switch is pressed 2828 f42a ad 80 02 lda SWCHA ; then check the soft "select" joysick code... 2829 f42d 29 b0 and #%10110000 ; R_DU 2830 f42f endif ; MOUSESUPPORT 2831 f42f checkselectswitchreturn 2832 f42f 60 rts 2833 f430 2834 f430 checkresetswitch 2835 f430 ad 82 02 lda SWCHB ; first check the real reset switch... 2836 f433 29 01 and #%00000001 2837 f435 ifnconst MOUSESUPPORT 2838 f435 f0 05 beq checkresetswitchreturn ; switch is pressed 2839 f437 ad 80 02 lda SWCHA ; then check the soft "reset" joysick code... 2840 f43a 29 70 and #%01110000 ; _LDU 2841 f43c endif ; MOUSESUPPORT 2842 f43c checkresetswitchreturn 2843 f43c 60 rts 2844 f43d 2845 f43d - ifconst FINESCROLLENABLED 2846 f43d -finescrolldlls 2847 f43d - ldx temp1 ; first DLL index x3 2848 f43d - lda DLLMEM,x 2849 f43d - and #%11110000 2850 f43d - ora finescrolly 2851 f43d - sta DLLMEM,x 2852 f43d - 2853 f43d - ldx temp2 ; last DLL index x3 2854 f43d - lda DLLMEM,x 2855 f43d - and #%11110000 2856 f43d - ora finescrolly 2857 f43d - eor #(WZONEHEIGHT-1) 2858 f43d - sta DLLMEM,x 2859 f43d - rts 2860 f43d endif ; FINESCROLLENABLED 2861 f43d 2862 f43d - ifconst USED_ADJUSTVISIBLE 2863 f43d -adjustvisible 2864 f43d - ; called with temp1=first visible zone *3, temp2=last visible zone *3 2865 f43d - jsr waitforvblankstart ; ensure vblank just started 2866 f43d - ldx visibleDLLstart 2867 f43d -findfirstinterrupt 2868 f43d - lda DLLMEM,x 2869 f43d - bmi foundfirstinterrupt 2870 f43d - inx 2871 f43d - inx 2872 f43d - inx 2873 f43d - bne findfirstinterrupt 2874 f43d -foundfirstinterrupt 2875 f43d - and #%01111111 ; clear the interrupt bit 2876 f43d - sta DLLMEM,x 2877 f43d - ifconst DOUBLEBUFFER 2878 f43d - sta DLLMEM+DBOFFSET,x 2879 f43d - endif ; DOUBLEBUFFER 2880 f43d - ldx overscanDLLstart 2881 f43d -findlastinterrupt 2882 f43d - lda DLLMEM,x 2883 f43d - bmi foundlastinterrupt 2884 f43d - dex 2885 f43d - dex 2886 f43d - dex 2887 f43d - bne findlastinterrupt 2888 f43d -foundlastinterrupt 2889 f43d - and #%01111111 ; clear the interrupt bit 2890 f43d - sta DLLMEM,x 2891 f43d - ifconst DOUBLEBUFFER 2892 f43d - sta DLLMEM+DBOFFSET,x 2893 f43d - endif ; DOUBLEBUFFER 2894 f43d - ;now we need to set the new interrupts 2895 f43d - clc 2896 f43d - lda temp1 2897 f43d - adc visibleDLLstart 2898 f43d - tax 2899 f43d - lda DLLMEM,x 2900 f43d - ora #%10000000 2901 f43d - sta DLLMEM,x 2902 f43d - ifconst DOUBLEBUFFER 2903 f43d - sta DLLMEM+DBOFFSET,x 2904 f43d - endif ; DOUBLEBUFFER 2905 f43d - clc 2906 f43d - lda temp2 2907 f43d - adc visibleDLLstart 2908 f43d - tax 2909 f43d - lda DLLMEM,x 2910 f43d - ora #%10000000 2911 f43d - sta DLLMEM,x 2912 f43d - ifconst DOUBLEBUFFER 2913 f43d - sta DLLMEM+DBOFFSET,x 2914 f43d - endif ; DOUBLEBUFFER 2915 f43d - jsr vblankresync 2916 f43d - rts 2917 f43d endif ; USED_ADJUSTVISIBLE 2918 f43d 2919 f43d vblankresync 2920 f43d 20 db f4 jsr waitforvblankstart ; ensure vblank just started 2921 f440 a9 00 lda #0 2922 f442 85 4d sta visibleover 2923 f444 a9 03 lda #3 2924 f446 8d b2 01 sta interruptindex 2925 f449 60 rts 2926 f44a 2927 f44a createallgamedlls 2928 f44a a2 00 ldx #0 2929 f44c a9 19 lda #NVLINES 2930 f44e ac 09 21 ldy paldetected 2931 f451 f0 03 beq skipcreatePALpadding 2932 f453 18 clc 2933 f454 69 15 adc #21 2934 f456 skipcreatePALpadding 2935 f456 20 8b f4 jsr createnonvisibledlls 2936 f459 8e 3c 21 stx visibleDLLstart 2937 f45c 20 bc f4 jsr createvisiblezones 2938 f45f 8e 3d 21 stx overscanDLLstart 2939 f462 createallgamedllscontinue 2940 f462 a9 50 lda #(NVLINES+55) ; extras for PAL 2941 f464 20 8b f4 jsr createnonvisibledlls 2942 f467 2943 f467 ae 3c 21 ldx visibleDLLstart 2944 f46a bd 00 18 lda DLLMEM,x 2945 f46d 09 80 ora #%10000000 ; NMI 1 - start of visible screen 2946 f46f 9d 00 18 sta DLLMEM,x 2947 f472 - ifconst DOUBLEBUFFER 2948 f472 - sta DLLMEM+DBOFFSET,x 2949 f472 endif ; DOUBLEBUFFER 2950 f472 2951 f472 ae 3d 21 ldx overscanDLLstart 2952 f475 bd 00 18 lda DLLMEM,x 2953 f478 09 83 ora #%10000011 ; NMI 2 - end of visible screen 2954 f47a 29 f3 and #%11110011 ; change this to a 1-line DLL, so there's time enough for the "deeper overscan" DLL 2955 f47c 9d 00 18 sta DLLMEM,x 2956 f47f - ifconst DOUBLEBUFFER 2957 f47f - sta DLLMEM+DBOFFSET,x 2958 f47f endif ; DOUBLEBUFFER 2959 f47f 2960 f47f e8 inx 2961 f480 e8 inx 2962 f481 e8 inx 2963 f482 2964 f482 bd 00 18 lda DLLMEM,x 2965 f485 09 80 ora #%10000000 ; NMI 3 - deeper overscan 2966 f487 9d 00 18 sta DLLMEM,x 2967 f48a - ifconst DOUBLEBUFFER 2968 f48a - sta DLLMEM+DBOFFSET,x 2969 f48a endif ; DOUBLEBUFFER 2970 f48a 2971 f48a 60 rts 2972 f48b 2973 f48b createnonvisibledlls 2974 f48b 85 42 sta temp1 2975 f48d 4a lsr 2976 f48e 4a lsr 2977 f48f 4a lsr 2978 f490 4a lsr ; /16 2979 f491 f0 09 beq skipcreatenonvisibledlls1loop 2980 f493 a8 tay 2981 f494 createnonvisibledlls1loop 2982 f494 a9 4f lda #%01001111 ;low nibble=16 lines, high nibble=Holey DMA 2983 f496 20 ab f4 jsr createblankdllentry 2984 f499 88 dey 2985 f49a d0 f8 bne createnonvisibledlls1loop 2986 f49c skipcreatenonvisibledlls1loop 2987 f49c a5 42 lda temp1 2988 f49e 29 0f and #%00001111 2989 f4a0 f0 08 beq createnonvisibledllsreturn 2990 f4a2 38 sec 2991 f4a3 e9 01 sbc #1 2992 f4a5 09 40 ora #%01000000 2993 f4a7 20 ab f4 jsr createblankdllentry 2994 f4aa createnonvisibledllsreturn 2995 f4aa 60 rts 2996 f4ab 2997 f4ab createblankdllentry 2998 f4ab 9d 00 18 sta DLLMEM,x 2999 f4ae - ifconst DOUBLEBUFFER 3000 f4ae - sta DLLMEM+DBOFFSET,x 3001 f4ae endif ; DOUBLEBUFFER 3002 f4ae e8 inx 3003 f4af a9 21 lda #$21 ; blank 3004 f4b1 9d 00 18 sta DLLMEM,x 3005 f4b4 - ifconst DOUBLEBUFFER 3006 f4b4 - sta DLLMEM+DBOFFSET,x 3007 f4b4 endif ; DOUBLEBUFFER 3008 f4b4 e8 inx 3009 f4b5 a9 00 lda #$00 3010 f4b7 9d 00 18 sta DLLMEM,x 3011 f4ba - ifconst DOUBLEBUFFER 3012 f4ba - sta DLLMEM+DBOFFSET,x 3013 f4ba endif ; DOUBLEBUFFER 3014 f4ba e8 inx 3015 f4bb 60 rts 3016 f4bc 3017 f4bc createvisiblezones 3018 f4bc a0 00 ldy #0 3019 f4be createvisiblezonesloop 3020 f4be b9 f3 f5 lda.w DLHEIGHT,y 3021 f4c1 09 40 ora #(WZONEHEIGHT * 4) ; set Holey DMA for 8 or 16 tall zones 3022 f4c3 9d 00 18 sta DLLMEM,x 3023 f4c6 - ifconst DOUBLEBUFFER 3024 f4c6 - sta DLLMEM+DBOFFSET,x 3025 f4c6 endif ; DOUBLEBUFFER 3026 f4c6 e8 inx 3027 f4c7 b9 db f5 lda DLPOINTH,y 3028 f4ca 9d 00 18 sta DLLMEM,x 3029 f4cd - ifconst DOUBLEBUFFER 3030 f4cd - sta DLLMEM+DBOFFSET,x 3031 f4cd endif ; DOUBLEBUFFER 3032 f4cd e8 inx 3033 f4ce b9 e7 f5 lda DLPOINTL,y 3034 f4d1 9d 00 18 sta DLLMEM,x 3035 f4d4 - ifconst DOUBLEBUFFER 3036 f4d4 - clc 3037 f4d4 - adc #DOUBLEBUFFEROFFSET 3038 f4d4 - sta DLLMEM+DBOFFSET,x 3039 f4d4 - bcc skiphidoublebufferadjust ; dlls are big endian, so we need to fix the hi byte after-the-fact... 3040 f4d4 - inc DLLMEM+DBOFFSET-1,x 3041 f4d4 -skiphidoublebufferadjust 3042 f4d4 endif ; DOUBLEBUFFER 3043 f4d4 e8 inx 3044 f4d5 c8 iny 3045 f4d6 c0 0c cpy #WZONECOUNT 3046 f4d8 d0 e4 bne createvisiblezonesloop 3047 f4da 60 rts 3048 f4db 3049 f4db waitforvblankstart 3050 f4db visibleoverwait 3051 f4db 24 28 BIT MSTAT 3052 f4dd 10 fc bpl visibleoverwait 3053 f4df vblankstartwait 3054 f4df 24 28 BIT MSTAT 3055 f4e1 30 fc bmi vblankstartwait 3056 f4e3 60 rts 3057 f4e4 3058 f4e4 - ifconst DOUBLEBUFFER 3059 f4e4 -flipdisplaybufferreturn 3060 f4e4 - rts 3061 f4e4 -flipdisplaybuffer 3062 f4e4 - lda doublebufferstate 3063 f4e4 - beq flipdisplaybufferreturn ; exit if we're not in double-buffer 3064 f4e4 - 3065 f4e4 - jsr terminatedisplaybuffer ; terminate the working buffer before we flip 3066 f4e4 - 3067 f4e4 - lda doublebufferstate 3068 f4e4 - lsr ; /2, so we'll see 0 or 1, rather than 1 or 3 3069 f4e4 - tax 3070 f4e4 - 3071 f4e4 - ; ensure we don't flip mid-display. otherwise the displayed DL will be the one the game is working on. 3072 f4e4 - 3073 f4e4 -flipdisplaybufferwait1 3074 f4e4 - lda visibleover 3075 f4e4 - beq flipdisplaybufferwait1 3076 f4e4 - 3077 f4e4 -flipdisplaybufferwait 3078 f4e4 - lda visibleover 3079 f4e4 - bne flipdisplaybufferwait 3080 f4e4 - 3081 f4e4 - lda doublebufferminimumframetarget 3082 f4e4 - beq skipminimumframecode 3083 f4e4 - lda doublebufferminimumframeindex 3084 f4e4 - bne flipdisplaybufferwait1 3085 f4e4 - lda doublebufferminimumframetarget 3086 f4e4 - sta doublebufferminimumframeindex 3087 f4e4 -skipminimumframecode 3088 f4e4 - 3089 f4e4 - lda DLLMEMLutHi,x 3090 f4e4 - sta DPPH 3091 f4e4 - lda DLLMEMLutLo,x 3092 f4e4 - sta DPPL 3093 f4e4 - 3094 f4e4 - lda NewPageflipstate,x 3095 f4e4 - sta doublebufferstate 3096 f4e4 - lda NewPageflipoffset,x 3097 f4e4 - sta doublebufferdloffset 3098 f4e4 - 3099 f4e4 - lda doublebufferbufferdirty 3100 f4e4 - beq flipdisplaybufferreturn 3101 f4e4 - 3102 f4e4 - ; The doublebuffer buffer is dirty, so the game code must have issued a savescreen recently. 3103 f4e4 - ; To make savescreen work with the new working buffer, we need to copy over the saved objects 3104 f4e4 - ; from the displayed buffer to the working buffer... 3105 f4e4 - 3106 f4e4 - lda doublebufferdloffset 3107 f4e4 - eor #DOUBLEBUFFEROFFSET 3108 f4e4 - sta temp6 ; make temp6 the anti-doublebufferdloffset variable 3109 f4e4 - 3110 f4e4 - ldx #(WZONECOUNT-1) 3111 f4e4 -copybufferzoneloop 3112 f4e4 - 3113 f4e4 - lda DLPOINTL,x 3114 f4e4 - clc 3115 f4e4 - adc doublebufferdloffset 3116 f4e4 - sta temp1 3117 f4e4 - lda DLPOINTH,x 3118 f4e4 - adc #0 3119 f4e4 - sta temp2 3120 f4e4 - 3121 f4e4 - lda DLPOINTL,x 3122 f4e4 - clc 3123 f4e4 - adc temp6 3124 f4e4 - sta temp3 3125 f4e4 - lda DLPOINTH,x 3126 f4e4 - adc #0 3127 f4e4 - sta temp4 3128 f4e4 - 3129 f4e4 - lda dlendsave,x 3130 f4e4 - tay 3131 f4e4 -copybuffercharsloop 3132 f4e4 - lda (temp3),y 3133 f4e4 - sta (temp1),y 3134 f4e4 - dey 3135 f4e4 - bpl copybuffercharsloop 3136 f4e4 - dex 3137 f4e4 - bpl copybufferzoneloop 3138 f4e4 - lda #0 3139 f4e4 - sta doublebufferbufferdirty 3140 f4e4 - rts 3141 f4e4 - 3142 f4e4 -doublebufferoff 3143 f4e4 - lda #1 3144 f4e4 - sta doublebufferstate 3145 f4e4 - jsr flipdisplaybuffer 3146 f4e4 - lda #0 3147 f4e4 - sta doublebufferstate 3148 f4e4 - sta doublebufferdloffset 3149 f4e4 - rts 3150 f4e4 - 3151 f4e4 -DLLMEMLutLo 3152 f4e4 - .byte DLLMEM,>(DLLMEM+DBOFFSET) 3155 f4e4 -NewPageflipstate 3156 f4e4 - .byte 3,1 3157 f4e4 -NewPageflipoffset 3158 f4e4 - .byte DOUBLEBUFFEROFFSET,0 3159 f4e4 - 3160 f4e4 endif ; DOUBLEBUFFER 3161 f4e4 3162 f4e4 - ifconst MOUSESUPPORT 3163 f4e4 - 3164 f4e4 -rotationalcompare 3165 f4e4 - ; old = 00 01 10 11 3166 f4e4 - .byte $00, $01, $ff, $00 ; new=00 3167 f4e4 - .byte $ff, $00, $00, $01 ; new=01 3168 f4e4 - .byte $01, $00, $00, $ff ; new=10 3169 f4e4 - .byte $00, $ff, $01, $00 ; new=11 3170 f4e4 - 3171 f4e4 - ; 0000YyXx st mouse 3172 f4e4 - 3173 f4e4 - ; 0000xyXY amiga mouse 3174 f4e4 - 3175 f4e4 - ifconst MOUSEXONLY 3176 f4e4 -amigatoataribits ; swap bits 1 and 4... 3177 f4e4 - .byte %0000, %0000, %0010, %0010 3178 f4e4 - .byte %0000, %0000, %0010, %0010 3179 f4e4 - .byte %0001, %0001, %0011, %0011 3180 f4e4 - .byte %0001, %0001, %0011, %0011 3181 f4e4 - 3182 f4e4 - ; null change bits 3183 f4e4 - .byte %0000, %0001, %0010, %0011 3184 f4e4 - .byte %0000, %0001, %0010, %0011 3185 f4e4 - .byte %0000, %0001, %0010, %0011 3186 f4e4 - .byte %0000, %0001, %0010, %0011 3187 f4e4 - 3188 f4e4 - else ; !MOUSEXONLY 3189 f4e4 - 3190 f4e4 -amigatoataribits ; swap bits 1 and 4... 3191 f4e4 - .byte %0000, %1000, %0010, %1010 3192 f4e4 - .byte %0100, %1100, %0110, %1110 3193 f4e4 - .byte %0001, %1001, %0011, %1011 3194 f4e4 - .byte %0101, %1101, %0111, %1111 3195 f4e4 - ; null change bits 3196 f4e4 - .byte %0000, %0001, %0010, %0011 3197 f4e4 - .byte %0100, %0101, %0110, %0111 3198 f4e4 - .byte %1000, %1001, %1010, %1011 3199 f4e4 - .byte %1100, %1101, %1110, %1111 3200 f4e4 - endif ; !MOUSEXONLY 3201 f4e4 - 3202 f4e4 endif ; MOUSESUPPORT 3203 f4e4 3204 f4e4 mouse0update 3205 f4e4 - ifconst MOUSE0SUPPORT 3206 f4e4 - 3207 f4e4 -mousetableselect = inttemp2 3208 f4e4 -mousexdelta = inttemp3 3209 f4e4 -mouseydelta = inttemp4 3210 f4e4 -lastSWCHA = inttemp6 3211 f4e4 - 3212 f4e4 - ; 0000YyXx st mouse 3213 f4e4 - ; 0000xyXY amiga mouse 3214 f4e4 - 3215 f4e4 - lda #$ff 3216 f4e4 - sta lastSWCHA 3217 f4e4 - 3218 f4e4 - ldy port0control 3219 f4e4 - 3220 f4e4 - lda #%00010000 3221 f4e4 - cpy #9 ; AMIGA? 3222 f4e4 - bne skipamigabitsfix0 3223 f4e4 - lda #0 3224 f4e4 -skipamigabitsfix0 3225 f4e4 - sta mousetableselect 3226 f4e4 - ifconst DRIVINGBOOST 3227 f4e4 - cpy #6 ; DRIVING? 3228 f4e4 - bne skipdriving0setup 3229 f4e4 - ; swap mousex0 and mousey0. mousex seen by the 7800basic program 3230 f4e4 - ; trails the actual mousex0, so we can smoothly interpolate toward 3231 f4e4 - ; the actual position. This actual position is stored in mousey0 3232 f4e4 - ; after the driver has run. 3233 f4e4 - ldx mousex0 3234 f4e4 - lda mousey0 3235 f4e4 - stx mousey0 3236 f4e4 - sta mousex0 3237 f4e4 -skipdriving0setup 3238 f4e4 - endif ; DRIVINGBOOST 3239 f4e4 - 3240 f4e4 - lda #0 3241 f4e4 - sta mousexdelta 3242 f4e4 - sta mouseydelta 3243 f4e4 - 3244 f4e4 - ifnconst MOUSETIME 3245 f4e4 - ifnconst MOUSEXONLY 3246 f4e4 - lda #180 ; minimum for x+y 3247 f4e4 - else 3248 f4e4 - lda #100 ; minimum for just x 3249 f4e4 - endif 3250 f4e4 - else 3251 f4e4 - lda #MOUSETIME 3252 f4e4 - endif 3253 f4e4 - jsr SETTIM64T ; INTIM is in Y 3254 f4e4 - 3255 f4e4 -mouse0updateloop 3256 f4e4 - lda SWCHA 3257 f4e4 - asr #%11110000 ; Undocumented. A = A & #IMM, then LSR A. 3258 f4e4 - cmp lastSWCHA 3259 f4e4 - beq mouse0loopcondition 3260 f4e4 - sta lastSWCHA 3261 f4e4 - lsr 3262 f4e4 - lsr 3263 f4e4 - lsr 3264 f4e4 - 3265 f4e4 - ora mousetableselect ; atari/amiga decoding table selection 3266 f4e4 - 3267 f4e4 - ; st mice encode on different bits/joystick-lines than amiga mice... 3268 f4e4 - ; 0000YyXx st mouse 3269 f4e4 - ; 0000xyXY amiga mouse 3270 f4e4 - ; ...so can shuffle the amiga bits to reuse the st driver. 3271 f4e4 - tay 3272 f4e4 - lax amigatoataribits,y 3273 f4e4 - 3274 f4e4 - ifnconst MOUSEXONLY 3275 f4e4 - ; first the Y... 3276 f4e4 - and #%00001100 3277 f4e4 - ora mousecodey0 3278 f4e4 - tay 3279 f4e4 - lda rotationalcompare,y 3280 f4e4 - clc 3281 f4e4 - adc mouseydelta 3282 f4e4 - sta mouseydelta 3283 f4e4 - tya 3284 f4e4 - lsr 3285 f4e4 - lsr 3286 f4e4 - sta mousecodey0 3287 f4e4 - txa 3288 f4e4 - ; ...then the X... 3289 f4e4 - and #%00000011 3290 f4e4 - tax 3291 f4e4 - endif ; !MOUSEXONLY 3292 f4e4 - 3293 f4e4 - asl 3294 f4e4 - asl 3295 f4e4 - ora mousecodex0 3296 f4e4 - tay 3297 f4e4 - lda rotationalcompare,y 3298 f4e4 - adc mousexdelta ; carry was clear by previous ASL 3299 f4e4 - sta mousexdelta 3300 f4e4 - stx mousecodex0 3301 f4e4 -mouse0loopcondition 3302 f4e4 - lda TIMINT 3303 f4e4 - bpl mouse0updateloop 3304 f4e4 - 3305 f4e4 - ; *** adapt to selected device resolution. 3306 f4e4 - ldx port0control 3307 f4e4 - 3308 f4e4 - ifconst PRECISIONMOUSING 3309 f4e4 - ldy port0resolution 3310 f4e4 - bne mouse0halveddone 3311 f4e4 - cpx #6 ; half-resolution is no good for driving wheels 3312 f4e4 - beq mouse0halveddone 3313 f4e4 - ; resolution=0 is half mouse resolution, necessary for precision 3314 f4e4 - ; mousing on a 160x240 screen with a 1000 dpi mouse. 3315 f4e4 - 3316 f4e4 - lda mousexdelta 3317 f4e4 - cmp #$80 3318 f4e4 - ror ; do a signed divide by 2. 3319 f4e4 - clc 3320 f4e4 - adc mousex0 3321 f4e4 - sta mousex0 3322 f4e4 - ifnconst MOUSEXONLY 3323 f4e4 - lda mouseydelta 3324 f4e4 - clc 3325 f4e4 - adc mousey0 3326 f4e4 - sta mousey0 3327 f4e4 - endif 3328 f4e4 - ; at half resolution we just exit after updating x and y 3329 f4e4 - jmp LLRET0 3330 f4e4 -mouse0halveddone 3331 f4e4 - endif ; PRECISIONMOUSING 3332 f4e4 - 3333 f4e4 - ifnconst MOUSEXONLY 3334 f4e4 - asl mouseydelta ; *2 because Y resolution is finer 3335 f4e4 - ldy port0resolution 3336 f4e4 - dey 3337 f4e4 - lda #0 3338 f4e4 -mousey0resolutionfix 3339 f4e4 - clc 3340 f4e4 - adc mouseydelta 3341 f4e4 - dey 3342 f4e4 - bpl mousey0resolutionfix 3343 f4e4 - clc 3344 f4e4 - adc mousey0 3345 f4e4 - sta mousey0 3346 f4e4 - endif ; MOUSEXONLY 3347 f4e4 - 3348 f4e4 - ldy port0resolution 3349 f4e4 - dey 3350 f4e4 - lda #0 3351 f4e4 -mousex0resolutionfix 3352 f4e4 - clc 3353 f4e4 - adc mousexdelta 3354 f4e4 - dey 3355 f4e4 - bpl mousex0resolutionfix 3356 f4e4 - ifnconst DRIVINGBOOST 3357 f4e4 - clc 3358 f4e4 - adc mousex0 3359 f4e4 - sta mousex0 3360 f4e4 - else 3361 f4e4 - cpx #6 3362 f4e4 - beq carryonmouse0boost 3363 f4e4 - clc 3364 f4e4 - adc mousex0 3365 f4e4 - sta mousex0 3366 f4e4 - jmp LLRET0 3367 f4e4 -carryonmouse0boost 3368 f4e4 - sta mousexdelta 3369 f4e4 - clc 3370 f4e4 - adc mousecodey0 3371 f4e4 - sta mousecodey0 3372 f4e4 - clc 3373 f4e4 - adc mousex0 3374 f4e4 - tay ; save the target X 3375 f4e4 - adc mousey0 ; average in the smoothly-trailing X 3376 f4e4 - ror 3377 f4e4 - sta mousex0 ; mousex0 now has the smoothly trailing X 3378 f4e4 - sty mousey0 ; and mousey0 has the the target X 3379 f4e4 - 3380 f4e4 - ; check to see if the coordinate wrapped. If so, undo the averaging code. 3381 f4e4 - ; A has mousex0, the smoothly trailing X 3382 f4e4 - sbc mousey0 ; less the target X 3383 f4e4 - bpl skipabsolutedrive0 3384 f4e4 - eor #$ff 3385 f4e4 -skipabsolutedrive0 3386 f4e4 - cmp #64 ; just an unreasonably large change 3387 f4e4 - bcc skipdrivewrapfix0 3388 f4e4 - sty mousex0 ; if X wrapped, we catch the trailing X up to the target X 3389 f4e4 -skipdrivewrapfix0 3390 f4e4 - 3391 f4e4 - ; get rid of the tweening if the distance travelled was very small 3392 f4e4 - lda mousexdelta 3393 f4e4 - cmp port0resolution 3394 f4e4 - bcs skipbetweenfix0 3395 f4e4 - lda mousex0 3396 f4e4 - sta mousey0 3397 f4e4 -skipbetweenfix0 3398 f4e4 - 3399 f4e4 -drivingboostreductioncheck0 3400 f4e4 - ; The below code amounts to mousecodey0=mousecodey0-(mousecodey0/8) 3401 f4e4 - ; +ve mousecodey0 is converted to -ve to do the calculation, and then 3402 f4e4 - ; negated again because truncation during BCD math results in 3403 f4e4 - ; differing magnitudes, depending if the value is +ve or -ve. 3404 f4e4 -driving0fix 3405 f4e4 - lax mousecodey0 3406 f4e4 - cmp #$80 3407 f4e4 - bcs driving0skipnegate1 3408 f4e4 - eor #$FF 3409 f4e4 - adc #1 3410 f4e4 - sta mousecodey0 3411 f4e4 -driving0skipnegate1 3412 f4e4 - cmp #$80 3413 f4e4 - ror 3414 f4e4 - cmp #$80 3415 f4e4 - ror 3416 f4e4 - cmp #$80 3417 f4e4 - ror 3418 f4e4 - sta inttemp1 3419 f4e4 - lda mousecodey0 3420 f4e4 - sec 3421 f4e4 - sbc inttemp1 3422 f4e4 - cpx #$80 3423 f4e4 - bcs driving0skipnegate2 3424 f4e4 - eor #$FF 3425 f4e4 - adc #1 3426 f4e4 -driving0skipnegate2 3427 f4e4 - sta mousecodey0 3428 f4e4 -drivingboostdone0 3429 f4e4 - endif ; DRIVINGBOOST 3430 f4e4 - 3431 f4e4 - jmp LLRET0 3432 f4e4 - 3433 f4e4 endif ; MOUSE0SUPPORT 3434 f4e4 3435 f4e4 mouse1update 3436 f4e4 - ifconst MOUSE1SUPPORT 3437 f4e4 - 3438 f4e4 -mousetableselect = inttemp2 3439 f4e4 -mousexdelta = inttemp3 3440 f4e4 -mouseydelta = inttemp4 3441 f4e4 -lastSWCHA = inttemp6 3442 f4e4 - 3443 f4e4 - ; 0000YyXx st mouse 3444 f4e4 - ; 0000xyXY amiga mouse 3445 f4e4 - 3446 f4e4 - lda #$ff 3447 f4e4 - sta lastSWCHA 3448 f4e4 - 3449 f4e4 - ldy port1control 3450 f4e4 - 3451 f4e4 - lda #%00010000 3452 f4e4 - cpy #9 ; AMIGA? 3453 f4e4 - bne skipamigabitsfix1 3454 f4e4 - lda #0 3455 f4e4 -skipamigabitsfix1 3456 f4e4 - sta mousetableselect 3457 f4e4 - ifconst DRIVINGBOOST 3458 f4e4 - cpy #6 ; DRIVING? 3459 f4e4 - bne skipdriving1setup 3460 f4e4 - ; swap mousex1 and mousey1. mousex seen by the 7800basic program 3461 f4e4 - ; trails the actual mousex1, so we can smoothly interpolate toward 3462 f4e4 - ; the actual position. This actual position is stored in mousey1 3463 f4e4 - ; after the driver has run. 3464 f4e4 - ldx mousex1 3465 f4e4 - lda mousey1 3466 f4e4 - stx mousey1 3467 f4e4 - sta mousex1 3468 f4e4 -skipdriving1setup 3469 f4e4 - endif ; DRIVINGBOOST 3470 f4e4 - 3471 f4e4 - lda #0 3472 f4e4 - sta mousexdelta 3473 f4e4 - sta mouseydelta 3474 f4e4 - 3475 f4e4 - ifnconst MOUSETIME 3476 f4e4 - ifnconst MOUSEXONLY 3477 f4e4 - lda #180 ; minimum for x+y 3478 f4e4 - else 3479 f4e4 - lda #100 ; minimum for just x 3480 f4e4 - endif 3481 f4e4 - else 3482 f4e4 - lda #MOUSETIME 3483 f4e4 - endif 3484 f4e4 - jsr SETTIM64T ; INTIM is in Y 3485 f4e4 - 3486 f4e4 -mouse1updateloop 3487 f4e4 - lda SWCHA 3488 f4e4 - and #%00001111 3489 f4e4 - cmp lastSWCHA 3490 f4e4 - beq mouse1loopcondition 3491 f4e4 - sta lastSWCHA 3492 f4e4 - 3493 f4e4 - ora mousetableselect ; atari/amiga decoding table selection 3494 f4e4 - 3495 f4e4 - ; st mice encode on different bits/joystick-lines than amiga mice... 3496 f4e4 - ; 0000YyXx st mouse 3497 f4e4 - ; 0000xyXY amiga mouse 3498 f4e4 - ; ...so can shuffle the amiga bits to reuse the st driver. 3499 f4e4 - tay 3500 f4e4 - lax amigatoataribits,y 3501 f4e4 - 3502 f4e4 - ifnconst MOUSEXONLY 3503 f4e4 - ; first the Y... 3504 f4e4 - and #%00001100 3505 f4e4 - ora mousecodey1 3506 f4e4 - tay 3507 f4e4 - lda rotationalcompare,y 3508 f4e4 - clc 3509 f4e4 - adc mouseydelta 3510 f4e4 - sta mouseydelta 3511 f4e4 - tya 3512 f4e4 - lsr 3513 f4e4 - lsr 3514 f4e4 - sta mousecodey1 3515 f4e4 - txa 3516 f4e4 - ; ...then the X... 3517 f4e4 - and #%00000011 3518 f4e4 - tax 3519 f4e4 - endif ; !MOUSEXONLY 3520 f4e4 - 3521 f4e4 - asl 3522 f4e4 - asl 3523 f4e4 - ora mousecodex1 3524 f4e4 - tay 3525 f4e4 - lda rotationalcompare,y 3526 f4e4 - adc mousexdelta ; carry was clear by previous ASL 3527 f4e4 - sta mousexdelta 3528 f4e4 - stx mousecodex1 3529 f4e4 -mouse1loopcondition 3530 f4e4 - lda TIMINT 3531 f4e4 - bpl mouse1updateloop 3532 f4e4 - 3533 f4e4 - ; *** adapt to selected device resolution. 3534 f4e4 - ldx port1control 3535 f4e4 - 3536 f4e4 - ifconst PRECISIONMOUSING 3537 f4e4 - ldy port1resolution 3538 f4e4 - bne mouse1halveddone 3539 f4e4 - cpx #6 ; half-resolution is no good for driving wheels 3540 f4e4 - beq mouse1halveddone 3541 f4e4 - ; resolution=0 is half mouse resolution, necessary for precision 3542 f4e4 - ; mousing on a 160x240 screen with a 1000 dpi mouse. 3543 f4e4 - 3544 f4e4 - lda mousexdelta 3545 f4e4 - cmp #$80 3546 f4e4 - ror ; do a signed divide by 2. 3547 f4e4 - clc 3548 f4e4 - adc mousex1 3549 f4e4 - sta mousex1 3550 f4e4 - ifnconst MOUSEXONLY 3551 f4e4 - lda mouseydelta 3552 f4e4 - clc 3553 f4e4 - adc mousey1 3554 f4e4 - sta mousey1 3555 f4e4 - endif 3556 f4e4 - ; at half resolution we just exit after updating x and y 3557 f4e4 - jmp LLRET1 3558 f4e4 -mouse1halveddone 3559 f4e4 - endif ; PRECISIONMOUSING 3560 f4e4 - 3561 f4e4 - ifnconst MOUSEXONLY 3562 f4e4 - asl mouseydelta ; *2 because Y resolution is finer 3563 f4e4 - ldy port1resolution 3564 f4e4 - dey 3565 f4e4 - lda #0 3566 f4e4 -mousey1resolutionfix 3567 f4e4 - clc 3568 f4e4 - adc mouseydelta 3569 f4e4 - dey 3570 f4e4 - bpl mousey1resolutionfix 3571 f4e4 - clc 3572 f4e4 - adc mousey1 3573 f4e4 - sta mousey1 3574 f4e4 - endif ; MOUSEXONLY 3575 f4e4 - 3576 f4e4 - ldy port1resolution 3577 f4e4 - dey 3578 f4e4 - lda #0 3579 f4e4 -mousex1resolutionfix 3580 f4e4 - clc 3581 f4e4 - adc mousexdelta 3582 f4e4 - dey 3583 f4e4 - bpl mousex1resolutionfix 3584 f4e4 - ifnconst DRIVINGBOOST 3585 f4e4 - clc 3586 f4e4 - adc mousex1 3587 f4e4 - sta mousex1 3588 f4e4 - else 3589 f4e4 - cpx #6 3590 f4e4 - beq carryonmouse1boost 3591 f4e4 - clc 3592 f4e4 - adc mousex1 3593 f4e4 - sta mousex1 3594 f4e4 - jmp LLRET1 3595 f4e4 -carryonmouse1boost 3596 f4e4 - sta mousexdelta 3597 f4e4 - clc 3598 f4e4 - adc mousecodey1 3599 f4e4 - sta mousecodey1 3600 f4e4 - clc 3601 f4e4 - adc mousex1 3602 f4e4 - tay ; save the target X 3603 f4e4 - adc mousey1 ; average in the smoothly-trailing X 3604 f4e4 - ror 3605 f4e4 - sta mousex1 ; mousex0 now has the smoothly trailing X 3606 f4e4 - sty mousey1 ; and mousey0 has the the target X 3607 f4e4 - 3608 f4e4 - ; check to see if the coordinate wrapped. If so, undo the averaging code. 3609 f4e4 - ; A has mousex1, the smoothly trailing X 3610 f4e4 - sbc mousey1 ; less the target X 3611 f4e4 - bpl skipabsolutedrive1 3612 f4e4 - eor #$ff 3613 f4e4 -skipabsolutedrive1 3614 f4e4 - cmp #64 ; just an unreasonably large change 3615 f4e4 - bcc skipdrivewrapfix1 3616 f4e4 - sty mousex1 ; if X wrapped, we catch the trailing X up to the target X 3617 f4e4 -skipdrivewrapfix1 3618 f4e4 - 3619 f4e4 - ; get rid of the tweening if the distance travelled was very small 3620 f4e4 - lda mousexdelta 3621 f4e4 - cmp port1resolution 3622 f4e4 - bcs skipbetweenfix1 3623 f4e4 - lda mousex1 3624 f4e4 - sta mousey1 3625 f4e4 -skipbetweenfix1 3626 f4e4 - 3627 f4e4 -drivingboostreductioncheck1 3628 f4e4 - ; The below code amounts to mousecodey0=mousecodey0-(mousecodey0/8) 3629 f4e4 - ; +ve mousecodey0 is converted to -ve to do the calculation, and then 3630 f4e4 - ; negated again because truncation during BCD math results in 3631 f4e4 - ; differing magnitudes, depending if the value is +ve or -ve. 3632 f4e4 -driving1fix 3633 f4e4 - lax mousecodey1 3634 f4e4 - cmp #$80 3635 f4e4 - bcs driving0skipnegate1 3636 f4e4 - eor #$FF 3637 f4e4 - adc #1 3638 f4e4 - sta mousecodey1 3639 f4e4 -driving0skipnegate1 3640 f4e4 - cmp #$80 3641 f4e4 - ror 3642 f4e4 - cmp #$80 3643 f4e4 - ror 3644 f4e4 - cmp #$80 3645 f4e4 - ror 3646 f4e4 - sta inttemp1 3647 f4e4 - lda mousecodey1 3648 f4e4 - sec 3649 f4e4 - sbc inttemp1 3650 f4e4 - cpx #$80 3651 f4e4 - bcs driving1skipnegate2 3652 f4e4 - eor #$FF 3653 f4e4 - adc #1 3654 f4e4 -driving1skipnegate2 3655 f4e4 - sta mousecodey1 3656 f4e4 -drivingboostdone1 3657 f4e4 - endif ; DRIVINGBOOST 3658 f4e4 - 3659 f4e4 - jmp LLRET1 3660 f4e4 - 3661 f4e4 endif ; MOUSE1SUPPORT 3662 f4e4 3663 f4e4 3664 f4e4 trakball0update 3665 f4e4 - ifconst TRAKBALL0SUPPORT 3666 f4e4 - ifnconst TRAKTIME 3667 f4e4 - ifnconst TRAKXONLY 3668 f4e4 - lda #180 ; minimum for x+y 3669 f4e4 - else ; !TRAKXONLY 3670 f4e4 - lda #100 ; minimum for just x 3671 f4e4 - endif ; !TRAKXONLY 3672 f4e4 - else ; !TRAKTIME 3673 f4e4 - lda #TRAKTIME 3674 f4e4 - endif ; !TRAKTIME 3675 f4e4 - jsr SETTIM64T ; INTIM is in Y 3676 f4e4 - ldx #0 3677 f4e4 - ifnconst TRAKXONLY 3678 f4e4 - ldy #0 3679 f4e4 - endif ; TRAKXONLY 3680 f4e4 -trakball0updateloop 3681 f4e4 - lda SWCHA 3682 f4e4 - and #%00110000 3683 f4e4 - cmp trakballcodex0 3684 f4e4 - sta trakballcodex0 3685 f4e4 - beq trakball0movementXdone 3686 f4e4 - and #%00010000 3687 f4e4 - beq trakball0negativeX 3688 f4e4 -trakball0positiveX 3689 f4e4 - ;(2 from beq) 3690 f4e4 - inx ; 2 3691 f4e4 - jmp trakball0movementXdone ; 3 3692 f4e4 -trakball0negativeX 3693 f4e4 - ;(3 from beq) 3694 f4e4 - dex ; 2 3695 f4e4 - nop ; 2 3696 f4e4 -trakball0movementXdone 3697 f4e4 - 3698 f4e4 - ifnconst TRAKXONLY 3699 f4e4 - lda SWCHA 3700 f4e4 - and #%11000000 3701 f4e4 - cmp trakballcodey0 3702 f4e4 - sta trakballcodey0 3703 f4e4 - beq trakball0movementYdone 3704 f4e4 - and #%01000000 3705 f4e4 - beq trakball0negativeY 3706 f4e4 -trakball0positiveY 3707 f4e4 - ;(2 from beq) 3708 f4e4 - iny ; 2 3709 f4e4 - jmp trakball0movementYdone ; 3 3710 f4e4 -trakball0negativeY 3711 f4e4 - ;(3 from beq) 3712 f4e4 - dey ; 2 3713 f4e4 - nop ; 2 3714 f4e4 -trakball0movementYdone 3715 f4e4 - endif ; !TRAKXONLY 3716 f4e4 - 3717 f4e4 - lda TIMINT 3718 f4e4 - bpl trakball0updateloop 3719 f4e4 - lda #0 3720 f4e4 - cpx #0 3721 f4e4 - beq trakball0skipXadjust 3722 f4e4 - clc 3723 f4e4 -trakball0Xloop 3724 f4e4 - adc port0resolution 3725 f4e4 - dex 3726 f4e4 - bne trakball0Xloop 3727 f4e4 - clc 3728 f4e4 - adc trakballx0 3729 f4e4 - sta trakballx0 3730 f4e4 -trakball0skipXadjust 3731 f4e4 - ifnconst TRAKXONLY 3732 f4e4 - lda #0 3733 f4e4 - cpy #0 3734 f4e4 - beq trakball0skipYadjust 3735 f4e4 - clc 3736 f4e4 -trakball0yloop 3737 f4e4 - adc port0resolution 3738 f4e4 - dey 3739 f4e4 - bne trakball0yloop 3740 f4e4 - clc 3741 f4e4 - adc trakbally0 3742 f4e4 - sta trakbally0 3743 f4e4 -trakball0skipYadjust 3744 f4e4 - endif ; !TRAKXONLY 3745 f4e4 - 3746 f4e4 - jmp LLRET0 3747 f4e4 endif 3748 f4e4 3749 f4e4 3750 f4e4 3751 f4e4 trakball1update 3752 f4e4 - ifconst TRAKBALL1SUPPORT 3753 f4e4 - ifnconst TRAKTIME 3754 f4e4 - ifnconst TRAKXONLY 3755 f4e4 - lda #180 ; minimum for x+y 3756 f4e4 - else ; !TRAKXONLY 3757 f4e4 - lda #100 ; minimum for just x 3758 f4e4 - endif ; !TRAKXONLY 3759 f4e4 - else ; !TRAKTIME 3760 f4e4 - lda #TRAKTIME 3761 f4e4 - endif ; !TRAKTIME 3762 f4e4 - jsr SETTIM64T ; INTIM is in Y 3763 f4e4 - ldx #0 3764 f4e4 - ifnconst TRAKXONLY 3765 f4e4 - ldy #0 3766 f4e4 - endif ; TRAKXONLY 3767 f4e4 -trakball1updateloop 3768 f4e4 - lda SWCHA 3769 f4e4 - and #%00000011 3770 f4e4 - cmp trakballcodex1 3771 f4e4 - sta trakballcodex1 3772 f4e4 - beq trakball1movementXdone 3773 f4e4 - and #%00000001 3774 f4e4 - beq trakball1negativeX 3775 f4e4 -trakball1positiveX 3776 f4e4 - ;(2 from beq) 3777 f4e4 - inx ; 2 3778 f4e4 - jmp trakball1movementXdone ; 3 3779 f4e4 -trakball1negativeX 3780 f4e4 - ;(3 from beq) 3781 f4e4 - dex ; 2 3782 f4e4 - nop ; 2 3783 f4e4 -trakball1movementXdone 3784 f4e4 - 3785 f4e4 - ifnconst TRAKXONLY 3786 f4e4 - lda SWCHA 3787 f4e4 - and #%00001100 3788 f4e4 - cmp trakballcodey1 3789 f4e4 - sta trakballcodey1 3790 f4e4 - beq trakball1movementYdone 3791 f4e4 - and #%00000100 3792 f4e4 - beq trakball1negativeY 3793 f4e4 -trakball1positiveY 3794 f4e4 - ;(2 from beq) 3795 f4e4 - iny ; 2 3796 f4e4 - jmp trakball1movementYdone ; 3 3797 f4e4 -trakball1negativeY 3798 f4e4 - ;(3 from beq) 3799 f4e4 - dey ; 2 3800 f4e4 - nop ; 2 3801 f4e4 -trakball1movementYdone 3802 f4e4 - endif ; !TRAKXONLY 3803 f4e4 - 3804 f4e4 - lda TIMINT 3805 f4e4 - bpl trakball1updateloop 3806 f4e4 - lda #0 3807 f4e4 - cpx #0 3808 f4e4 - beq trakball1skipXadjust 3809 f4e4 - clc 3810 f4e4 -trakball1Xloop 3811 f4e4 - adc port1resolution 3812 f4e4 - dex 3813 f4e4 - bne trakball1Xloop 3814 f4e4 - clc 3815 f4e4 - adc trakballx1 3816 f4e4 - sta trakballx1 3817 f4e4 -trakball1skipXadjust 3818 f4e4 - ifnconst TRAKXONLY 3819 f4e4 - lda #0 3820 f4e4 - cpy #0 3821 f4e4 - beq trakball1skipYadjust 3822 f4e4 - clc 3823 f4e4 -trakball1yloop 3824 f4e4 - adc port1resolution 3825 f4e4 - dey 3826 f4e4 - bne trakball1yloop 3827 f4e4 - clc 3828 f4e4 - adc trakbally1 3829 f4e4 - sta trakbally1 3830 f4e4 -trakball1skipYadjust 3831 f4e4 - endif ; !TRAKXONLY 3832 f4e4 - 3833 f4e4 - jmp LLRET1 3834 f4e4 endif 3835 f4e4 3836 f4e4 3837 f4e4 paddleport0update 3838 f4e4 - ifconst PADDLE0SUPPORT 3839 f4e4 - lda #6 3840 f4e4 - sta VBLANK ; start charging the paddle caps 3841 f4e4 - lda #0 ; use PADDLE timing 3842 f4e4 - jsr SETTIM64T ; INTIM is in Y 3843 f4e4 - 3844 f4e4 -paddleport0updateloop 3845 f4e4 - lda INPT0 3846 f4e4 - bmi skippaddle0setposition 3847 f4e4 - sty paddleposition0 3848 f4e4 -skippaddle0setposition 3849 f4e4 - ifconst TWOPADDLESUPPORT 3850 f4e4 - lda INPT1 3851 f4e4 - bmi skippaddle1setposition 3852 f4e4 - sty paddleposition1 3853 f4e4 -skippaddle1setposition 3854 f4e4 - endif 3855 f4e4 - ldy INTIM 3856 f4e4 - cpy #TIMEOFFSET 3857 f4e4 - bcs paddleport0updateloop 3858 f4e4 - 3859 f4e4 - lda #%10000110 3860 f4e4 - sta VBLANK ; dump paddles to ground... this may not be great for genesis controllers 3861 f4e4 - sec 3862 f4e4 - lda paddleposition0 3863 f4e4 - sbc #TIMEOFFSET 3864 f4e4 - ifconst PADDLESCALEX2 3865 f4e4 - asl 3866 f4e4 - endif 3867 f4e4 - 3868 f4e4 - ifnconst PADDLESMOOTHINGOFF 3869 f4e4 - clc 3870 f4e4 - adc paddleprevious0 3871 f4e4 - ror 3872 f4e4 - sta paddleprevious0 3873 f4e4 - endif 3874 f4e4 - 3875 f4e4 - sta paddleposition0 3876 f4e4 - 3877 f4e4 - ifconst TWOPADDLESUPPORT 3878 f4e4 - sec 3879 f4e4 - lda paddleposition1 3880 f4e4 - sbc #TIMEOFFSET 3881 f4e4 - ifconst PADDLESCALEX2 3882 f4e4 - asl 3883 f4e4 - endif 3884 f4e4 - 3885 f4e4 - ifnconst PADDLESMOOTHINGOFF 3886 f4e4 - clc 3887 f4e4 - adc paddleprevious1 3888 f4e4 - ror 3889 f4e4 - sta paddleprevious1 3890 f4e4 - endif 3891 f4e4 - sta paddleposition1 3892 f4e4 - endif ; TWOPADDLESUPPORT 3893 f4e4 - 3894 f4e4 - jmp LLRET0 3895 f4e4 endif 3896 f4e4 3897 f4e4 paddleport1update 3898 f4e4 - ifconst PADDLE1SUPPORT 3899 f4e4 - lda #6 3900 f4e4 - sta VBLANK ; start charging the paddle caps 3901 f4e4 - 3902 f4e4 - lda #0 ; use PADDLE timing 3903 f4e4 - jsr SETTIM64T ; INTIM is in Y 3904 f4e4 - 3905 f4e4 -paddleport1updateloop 3906 f4e4 - lda INPT2 3907 f4e4 - bmi skippaddle2setposition 3908 f4e4 - sty paddleposition2 3909 f4e4 -skippaddle2setposition 3910 f4e4 - ifconst TWOPADDLESUPPORT 3911 f4e4 - lda INPT3 3912 f4e4 - bmi skippaddle3setposition 3913 f4e4 - sty paddleposition3 3914 f4e4 -skippaddle3setposition 3915 f4e4 - endif 3916 f4e4 - ldy INTIM 3917 f4e4 - cpy #TIMEOFFSET 3918 f4e4 - bcs paddleport1updateloop 3919 f4e4 - 3920 f4e4 - lda #%10000110 3921 f4e4 - sta VBLANK ; dump paddles to ground... this may not be great for genesis controllers 3922 f4e4 - sec 3923 f4e4 - lda paddleposition2 3924 f4e4 - sbc #TIMEOFFSET 3925 f4e4 - ifconst PADDLESCALEX2 3926 f4e4 - asl 3927 f4e4 - endif 3928 f4e4 - 3929 f4e4 - ifnconst PADDLESMOOTHINGOFF 3930 f4e4 - clc 3931 f4e4 - adc paddleprevious2 3932 f4e4 - ror 3933 f4e4 - sta paddleprevious2 3934 f4e4 - endif 3935 f4e4 - 3936 f4e4 - sta paddleposition2 3937 f4e4 - 3938 f4e4 - ifconst TWOPADDLESUPPORT 3939 f4e4 - sec 3940 f4e4 - lda paddleposition3 3941 f4e4 - sbc #TIMEOFFSET 3942 f4e4 - ifconst PADDLESCALEX2 3943 f4e4 - asl 3944 f4e4 - endif 3945 f4e4 - 3946 f4e4 - ifnconst PADDLESMOOTHINGOFF 3947 f4e4 - clc 3948 f4e4 - adc paddleprevious3 3949 f4e4 - ror 3950 f4e4 - sta paddleprevious3 3951 f4e4 - endif 3952 f4e4 - sta paddleposition3 3953 f4e4 - endif ; TWOPADDLESUPPORT 3954 f4e4 - 3955 f4e4 - jmp LLRET1 3956 f4e4 endif 3957 f4e4 3958 f4e4 3959 f4e4 paddlebuttonhandler ; outside of conditional, for button-handler LUT 3960 f4e4 - ifconst PADDLESUPPORT 3961 f4e4 - ; x=0|1 for port, rather than paddle #. 3962 f4e4 - ; Only the first paddle button will integrate into "joy0fire" testing. If the 3963 f4e4 - ; game wants to support 2 paddles, up to the game to instead test the 3964 f4e4 - ; joystick right+left directions instead. 3965 f4e4 - lda SWCHA ; top of nibble is first paddle button 3966 f4e4 - cpx #0 ; port 0? 3967 f4e4 - beq skippaddleport2shift 3968 f4e4 - asl ; shift second port to upper nibble 3969 f4e4 - asl 3970 f4e4 - asl 3971 f4e4 - asl 3972 f4e4 -skippaddleport2shift 3973 f4e4 - and #%10000000 3974 f4e4 - eor #%10000000 ; invert 3975 f4e4 - sta sINPT1,x 3976 f4e4 - jmp buttonreadloopreturn 3977 f4e4 endif ; PADDLESUPPORT 3978 f4e4 3979 f4e4 mousebuttonhandler ; outside of conditional, for button-handler LUT 3980 f4e4 - ifconst MOUSESUPPORT 3981 f4e4 - ; stick the mouse buttons in the correct shadow register... 3982 f4e4 - txa 3983 f4e4 - asl 3984 f4e4 - tay ; y=x*2 3985 f4e4 - lda INPT4,x 3986 f4e4 - eor #%10000000 3987 f4e4 - lsr 3988 f4e4 - sta sINPT1,x 3989 f4e4 - 3990 f4e4 - lda INPT1,y 3991 f4e4 - and #%10000000 3992 f4e4 - eor #%10000000 3993 f4e4 - ora sINPT1,x 3994 f4e4 - sta sINPT1,x 3995 f4e4 - jmp buttonreadloopreturn 3996 f4e4 endif ; MOUSESUPPORT 3997 f4e4 3998 f4e4 - ifconst KEYPADSUPPORT 3999 f4e4 - ; ** select keypad rows 0 to 3 over 4 frames... 4000 f4e4 -keypadrowselect 4001 f4e4 - ldy #0 4002 f4e4 - lda port0control 4003 f4e4 - cmp #7 4004 f4e4 - bne skipport0val 4005 f4e4 - iny ; y=y+1 4006 f4e4 -skipport0val 4007 f4e4 - lda port1control 4008 f4e4 - cmp #7 4009 f4e4 - bne skipport1val 4010 f4e4 - iny 4011 f4e4 - iny ; y=y+2 4012 f4e4 -skipport1val 4013 f4e4 - lda keyrowdirectionmask,y 4014 f4e4 - sta CTLSWA 4015 f4e4 - tya 4016 f4e4 - asl 4017 f4e4 - asl 4018 f4e4 - sta inttemp1 4019 f4e4 - lda framecounter 4020 f4e4 - and #3 4021 f4e4 - ora inttemp1 4022 f4e4 - tax 4023 f4e4 - lda keyrowselectvalue,x 4024 f4e4 - sta SWCHA 4025 f4e4 - rts 4026 f4e4 - 4027 f4e4 -keyrowdirectionmask 4028 f4e4 - .byte #%00000000 ; 0 : port0=input port1=input 4029 f4e4 - .byte #%11110000 ; 1 : port0=output port1=input 4030 f4e4 - .byte #%00001111 ; 2 : port0=input port1=output 4031 f4e4 - .byte #%11111111 ; 3 : port0=output port1=output 4032 f4e4 - 4033 f4e4 -keyrowselectvalue 4034 f4e4 - .byte #%00000000, #%00000000, #%00000000, #%00000000 ; no row selected, all pins high, always 4035 f4e4 - .byte #%11100000, #%11010000, #%10110000, #%01110000 ; p0 keypad in 4036 f4e4 - .byte #%00001110, #%00001101, #%00001011, #%00000111 ; p1 keypad in 4037 f4e4 - .byte #%11101110, #%11011101, #%10111011, #%01110111 ; p0+p1 keypads in 4038 f4e4 endif ; KEYPADSUPPORT 4039 f4e4 4040 f4e4 - ifconst KEYPADSUPPORT 4041 f4e4 - ; TODO - split into compile-time KEYPAD0SUPPORT and KEYPAD1SUPPORT 4042 f4e4 -keypadcolumnread 4043 f4e4 - lda port0control 4044 f4e4 - cmp #7 4045 f4e4 - bne skipkeypadcolumnread0 4046 f4e4 - lda framecounter 4047 f4e4 - and #3 4048 f4e4 - asl ; x2 because keypad variables are interleaved 4049 f4e4 - tax 4050 f4e4 - lda #0 4051 f4e4 - sta keypadmatrix0a,x 4052 f4e4 - lda INPT0 4053 f4e4 - cmp #$80 4054 f4e4 - rol keypadmatrix0a,x 4055 f4e4 - lda INPT1 4056 f4e4 - cmp #$80 4057 f4e4 - rol keypadmatrix0a,x 4058 f4e4 - lda INPT4 4059 f4e4 - cmp #$80 4060 f4e4 - rol keypadmatrix0a,x 4061 f4e4 - lda keypadmatrix0a,x 4062 f4e4 - eor #%00000111 4063 f4e4 - sta keypadmatrix0a,x 4064 f4e4 -skipkeypadcolumnread0 4065 f4e4 - 4066 f4e4 - lda port1control 4067 f4e4 - cmp #7 4068 f4e4 - bne skipkeypadcolumnread1 4069 f4e4 - lda framecounter 4070 f4e4 - and #3 4071 f4e4 - asl ; x2 because keypad variables are interleaved 4072 f4e4 - tax 4073 f4e4 - lda #0 4074 f4e4 - sta keypadmatrix1a,x 4075 f4e4 - rol keypadmatrix1a,x 4076 f4e4 - lda INPT2 4077 f4e4 - cmp #$80 4078 f4e4 - rol keypadmatrix1a,x 4079 f4e4 - lda INPT3 4080 f4e4 - cmp #$80 4081 f4e4 - rol keypadmatrix1a,x 4082 f4e4 - lda INPT5 4083 f4e4 - cmp #$80 4084 f4e4 - rol keypadmatrix1a,x 4085 f4e4 - lda keypadmatrix1a,x 4086 f4e4 - eor #%00000111 4087 f4e4 - sta keypadmatrix1a,x 4088 f4e4 -skipkeypadcolumnread1 4089 f4e4 - rts 4090 f4e4 endif ; KEYPADSUPPORT 4091 f4e4 4092 f4e4 setportforinput 4093 f4e4 a5 e4 lda CTLSWAs 4094 f4e6 3d ef f4 and allpinsinputlut,x 4095 f4e9 85 e4 sta CTLSWAs 4096 f4eb 8d 81 02 sta CTLSWA 4097 f4ee 60 rts 4098 f4ef 4099 f4ef allpinsinputlut 4100 f4ef 0f f0 .byte.b $0F, $F0 4101 f4f1 4102 f4f1 setonebuttonmode 4103 f4f1 a9 06 lda #6 ; in case we're in unlocked-bios mode 4104 f4f3 85 01 sta VBLANK ; if we were on paddles, the line is grounded out. 4105 f4f5 a9 14 lda #$14 4106 f4f7 8d 83 02 sta CTLSWB ; set both 2-button disable bits to writable 4107 f4fa a5 e5 lda CTLSWBs 4108 f4fc 1d 05 f5 ora thisjoy2buttonbit,x 4109 f4ff 85 e5 sta CTLSWBs 4110 f501 8d 82 02 sta SWCHB ; turn off the 2-button disable bits 4111 f504 60 rts 4112 f505 4113 f505 thisjoy2buttonbit 4114 f505 04 10 .byte.b $04, $10 4115 f507 4116 f507 settwobuttonmode 4117 f507 a9 06 lda #6 ; in case we're in unlocked-bios mode 4118 f509 85 01 sta VBLANK ; if we were on paddles, the line is grounded out. 4119 f50b a9 14 lda #$14 4120 f50d 8d 83 02 sta CTLSWB ; set both 2-button disable bits to writable 4121 f510 a5 e5 lda CTLSWBs 4122 f512 3d 1b f5 and thisjoy2buttonmask,x 4123 f515 85 e5 sta CTLSWBs 4124 f517 8d 82 02 sta SWCHB 4125 f51a 60 rts 4126 f51b 4127 f51b thisjoy2buttonmask 4128 f51b fb ef .byte.b $fb, $ef 4129 f51d 4130 f51d ; Provided under the CC0 license. See the included LICENSE.txt for details. 4131 f51d 4132 f51d START 4133 f51d start 4134 f51d 4135 f51d ;******** more or less the Atari recommended startup procedure 4136 f51d 4137 f51d 78 sei 4138 f51e d8 cld 4139 f51f 4140 f51f ifnconst NOTIALOCK 4141 f51f a9 07 lda #$07 4142 f521 - else 4143 f521 - lda #$06 4144 f521 endif 4145 f521 85 01 sta INPTCTRL ;lock 7800 into 7800 mode 4146 f523 a9 7f lda #$7F 4147 f525 85 3c sta CTRL ;disable DMA 4148 f527 a9 00 lda #$00 4149 f529 85 38 sta OFFSET 4150 f52b ifnconst NOTIALOCK 4151 f52b 85 01 sta INPTCTRL 4152 f52d endif 4153 f52d a2 ff ldx #$FF 4154 f52f 9a txs 4155 f530 4156 f530 ;************** Clear Memory 4157 f530 4158 f530 a2 40 ldx #$40 4159 f532 a9 00 lda #$00 4160 f534 crloop1 4161 f534 95 00 sta $00,x ;Clear zero page 4162 f536 9d 00 01 sta $100,x ;Clear page 1 4163 f539 e8 inx 4164 f53a d0 f8 bne crloop1 4165 f53c 4166 f53c 4167 f53c a0 00 ldy #$00 ;Clear Ram 4168 f53e a9 18 lda #$18 ;Start at $1800 4169 f540 85 81 sta $81 4170 f542 a9 00 lda #$00 4171 f544 85 80 sta $80 4172 f546 crloop3 4173 f546 a9 00 lda #$00 4174 f548 91 80 sta ($80),y ;Store data 4175 f54a c8 iny ;Next byte 4176 f54b d0 f9 bne crloop3 ;Branch if not done page 4177 f54d e6 81 inc $81 ;Next page 4178 f54f a5 81 lda $81 4179 f551 c9 20 cmp #$20 ;End at $1FFF 4180 f553 d0 f1 bne crloop3 ;Branch if not 4181 f555 4182 f555 a0 00 ldy #$00 ;Clear Ram 4183 f557 a9 22 lda #$22 ;Start at $2200 4184 f559 85 81 sta $81 4185 f55b a9 00 lda #$00 4186 f55d 85 80 sta $80 4187 f55f crloop4 4188 f55f a9 00 lda #$00 4189 f561 91 80 sta ($80),y ;Store data 4190 f563 c8 iny ;Next byte 4191 f564 d0 f9 bne crloop4 ;Branch if not done page 4192 f566 e6 81 inc $81 ;Next page 4193 f568 a5 81 lda $81 4194 f56a c9 27 cmp #$27 ;End at $27FF 4195 f56c d0 f1 bne crloop4 ;Branch if not 4196 f56e 4197 f56e a2 00 ldx #$00 4198 f570 a9 00 lda #$00 4199 f572 crloop5 ;Clear 2100-213F, 2000-203F 4200 f572 9d 00 20 sta $2000,x 4201 f575 9d 00 21 sta $2100,x 4202 f578 e8 inx 4203 f579 e0 40 cpx #$40 4204 f57b d0 f5 bne crloop5 4205 f57d 4206 f57d 85 80 sta $80 4207 f57f 85 81 sta $81 4208 f581 85 82 sta $82 4209 f583 85 83 sta $83 4210 f585 4211 f585 ;seed random number with hopefully-random timer value 4212 f585 a9 01 lda #1 4213 f587 0d 84 02 ora INTIM 4214 f58a 85 40 sta rand 4215 f58c 4216 f58c ; detect the console type... 4217 f58c pndetectvblankstart 4218 f58c a5 28 lda MSTAT 4219 f58e 10 fc bpl pndetectvblankstart ; if we're not in VBLANK, wait for it to start 4220 f590 pndetectvblankover 4221 f590 a5 28 lda MSTAT 4222 f592 30 fc bmi pndetectvblankover ; then wait for it to be over 4223 f594 a0 00 ldy #$00 4224 f596 a2 00 ldx #$00 4225 f598 pndetectvblankhappening 4226 f598 a5 28 lda MSTAT 4227 f59a 30 07 bmi pndetectinvblank ; if VBLANK starts, exit our counting loop 4228 f59c 85 24 sta WSYNC 4229 f59e 85 24 sta WSYNC 4230 f5a0 e8 inx 4231 f5a1 d0 f5 bne pndetectvblankhappening 4232 f5a3 pndetectinvblank 4233 f5a3 e0 7d cpx #125 4234 f5a5 90 02 bcc pndetecispal 4235 f5a7 a0 01 ldy #$01 4236 f5a9 pndetecispal 4237 f5a9 8c 09 21 sty paldetected 4238 f5ac 4239 f5ac 20 4a f4 jsr createallgamedlls 4240 f5af 4241 f5af a9 18 lda #>DLLMEM 4242 f5b1 85 2c sta DPPH 4243 f5b3 a9 00 lda # 255 4412 f5db -DOUBLEBUFFEROFFSET = 255 4413 f5db else 4414 f5db 00 9d DOUBLEBUFFEROFFSET = (DLLASTOBJ+2) 4415 f5db endif 4416 f5db 4417 f5db - ifconst EXTRADLMEMORY 4418 f5db -SECONDDLHALFSTART SET $2300 4419 f5db endif 4420 f5db 4421 f5db DLPOINTH 4422 f5db DLINDEX SET 0 4423 f5db REPEAT WZONECOUNT 4424 f5db TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5db - ifconst EXTRADLMEMORY 4426 f5db - if TMPMEMADDRESS > $1FFF 4427 f5db -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5db - else 4429 f5db - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5db -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5db -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5db - endif 4433 f5db - endif ; TMPMEMADDRESS > $1FFF 4434 f5db endif ; EXTRADLMEMORY 4435 f5db ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5db 18 .byte.b >TMPMEMADDRESS 4437 f5db DLINDEX SET DLINDEX + 1 4423 f5db REPEND 4424 f5db TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5dc - ifconst EXTRADLMEMORY 4426 f5dc - if TMPMEMADDRESS > $1FFF 4427 f5dc -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5dc - else 4429 f5dc - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5dc -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5dc -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5dc - endif 4433 f5dc - endif ; TMPMEMADDRESS > $1FFF 4434 f5dc endif ; EXTRADLMEMORY 4435 f5dc ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5dc 19 .byte.b >TMPMEMADDRESS 4437 f5dc DLINDEX SET DLINDEX + 1 4423 f5dc REPEND 4424 f5dc TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5dd - ifconst EXTRADLMEMORY 4426 f5dd - if TMPMEMADDRESS > $1FFF 4427 f5dd -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5dd - else 4429 f5dd - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5dd -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5dd -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5dd - endif 4433 f5dd - endif ; TMPMEMADDRESS > $1FFF 4434 f5dd endif ; EXTRADLMEMORY 4435 f5dd ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5dd 19 .byte.b >TMPMEMADDRESS 4437 f5dd DLINDEX SET DLINDEX + 1 4423 f5dd REPEND 4424 f5dd TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5de - ifconst EXTRADLMEMORY 4426 f5de - if TMPMEMADDRESS > $1FFF 4427 f5de -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5de - else 4429 f5de - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5de -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5de -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5de - endif 4433 f5de - endif ; TMPMEMADDRESS > $1FFF 4434 f5de endif ; EXTRADLMEMORY 4435 f5de ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5de 1a .byte.b >TMPMEMADDRESS 4437 f5de DLINDEX SET DLINDEX + 1 4423 f5de REPEND 4424 f5de TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5df - ifconst EXTRADLMEMORY 4426 f5df - if TMPMEMADDRESS > $1FFF 4427 f5df -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5df - else 4429 f5df - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5df -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5df -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5df - endif 4433 f5df - endif ; TMPMEMADDRESS > $1FFF 4434 f5df endif ; EXTRADLMEMORY 4435 f5df ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5df 1b .byte.b >TMPMEMADDRESS 4437 f5df DLINDEX SET DLINDEX + 1 4423 f5df REPEND 4424 f5df TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e0 - ifconst EXTRADLMEMORY 4426 f5e0 - if TMPMEMADDRESS > $1FFF 4427 f5e0 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e0 - else 4429 f5e0 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e0 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e0 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e0 - endif 4433 f5e0 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e0 endif ; EXTRADLMEMORY 4435 f5e0 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e0 1b .byte.b >TMPMEMADDRESS 4437 f5e0 DLINDEX SET DLINDEX + 1 4423 f5e0 REPEND 4424 f5e0 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e1 - ifconst EXTRADLMEMORY 4426 f5e1 - if TMPMEMADDRESS > $1FFF 4427 f5e1 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e1 - else 4429 f5e1 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e1 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e1 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e1 - endif 4433 f5e1 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e1 endif ; EXTRADLMEMORY 4435 f5e1 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e1 1c .byte.b >TMPMEMADDRESS 4437 f5e1 DLINDEX SET DLINDEX + 1 4423 f5e1 REPEND 4424 f5e1 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e2 - ifconst EXTRADLMEMORY 4426 f5e2 - if TMPMEMADDRESS > $1FFF 4427 f5e2 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e2 - else 4429 f5e2 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e2 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e2 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e2 - endif 4433 f5e2 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e2 endif ; EXTRADLMEMORY 4435 f5e2 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e2 1c .byte.b >TMPMEMADDRESS 4437 f5e2 DLINDEX SET DLINDEX + 1 4423 f5e2 REPEND 4424 f5e2 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e3 - ifconst EXTRADLMEMORY 4426 f5e3 - if TMPMEMADDRESS > $1FFF 4427 f5e3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e3 - else 4429 f5e3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e3 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e3 - endif 4433 f5e3 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e3 endif ; EXTRADLMEMORY 4435 f5e3 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e3 1d .byte.b >TMPMEMADDRESS 4437 f5e3 DLINDEX SET DLINDEX + 1 4423 f5e3 REPEND 4424 f5e3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e4 - ifconst EXTRADLMEMORY 4426 f5e4 - if TMPMEMADDRESS > $1FFF 4427 f5e4 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e4 - else 4429 f5e4 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e4 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e4 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e4 - endif 4433 f5e4 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e4 endif ; EXTRADLMEMORY 4435 f5e4 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e4 1e .byte.b >TMPMEMADDRESS 4437 f5e4 DLINDEX SET DLINDEX + 1 4423 f5e4 REPEND 4424 f5e4 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e5 - ifconst EXTRADLMEMORY 4426 f5e5 - if TMPMEMADDRESS > $1FFF 4427 f5e5 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e5 - else 4429 f5e5 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e5 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e5 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e5 - endif 4433 f5e5 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e5 endif ; EXTRADLMEMORY 4435 f5e5 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e5 1e .byte.b >TMPMEMADDRESS 4437 f5e5 DLINDEX SET DLINDEX + 1 4423 f5e5 REPEND 4424 f5e5 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4425 f5e6 - ifconst EXTRADLMEMORY 4426 f5e6 - if TMPMEMADDRESS > $1FFF 4427 f5e6 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4428 f5e6 - else 4429 f5e6 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4430 f5e6 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4431 f5e6 -SECONDDLHALFSTART SET TMPMEMADDRESS 4432 f5e6 - endif 4433 f5e6 - endif ; TMPMEMADDRESS > $1FFF 4434 f5e6 endif ; EXTRADLMEMORY 4435 f5e6 ;echo " "," ZONE",[DLINDEX]d,"ADDRESS: ",TMPMEMADDRESS 4436 f5e6 1f .byte.b >TMPMEMADDRESS 4437 f5e6 DLINDEX SET DLINDEX + 1 4438 f5e7 REPEND 4439 f5e7 4440 f5e7 - ifconst EXTRADLMEMORY 4441 f5e7 - echo " ",[SECONDDLHALFSTART],"to",[$27FF],"was claimed as extra DL memory." 4442 f5e7 endif 4443 f5e7 4444 f5e7 4445 f5e7 DLPOINTL 4446 f5e7 DLINDEX SET 0 4447 f5e7 REPEAT WZONECOUNT 4448 f5e7 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4449 f5e7 - ifconst EXTRADLMEMORY 4450 f5e7 - if TMPMEMADDRESS > $1FFF 4451 f5e7 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5e7 - else 4453 f5e7 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5e7 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5e7 - endif 4456 f5e7 - endif ; TMPMEMADDRESS > $1FFF 4457 f5e7 endif ; EXTRADLMEMORY 4458 f5e7 80 .byte.b $1FFF 4451 f5e8 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5e8 - else 4453 f5e8 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5e8 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5e8 - endif 4456 f5e8 - endif ; TMPMEMADDRESS > $1FFF 4457 f5e8 endif ; EXTRADLMEMORY 4458 f5e8 20 .byte.b $1FFF 4451 f5e9 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5e9 - else 4453 f5e9 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5e9 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5e9 - endif 4456 f5e9 - endif ; TMPMEMADDRESS > $1FFF 4457 f5e9 endif ; EXTRADLMEMORY 4458 f5e9 c0 .byte.b $1FFF 4451 f5ea -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5ea - else 4453 f5ea - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5ea -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5ea - endif 4456 f5ea - endif ; TMPMEMADDRESS > $1FFF 4457 f5ea endif ; EXTRADLMEMORY 4458 f5ea 60 .byte.b $1FFF 4451 f5eb -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5eb - else 4453 f5eb - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5eb -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5eb - endif 4456 f5eb - endif ; TMPMEMADDRESS > $1FFF 4457 f5eb endif ; EXTRADLMEMORY 4458 f5eb 00 .byte.b $1FFF 4451 f5ec -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5ec - else 4453 f5ec - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5ec -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5ec - endif 4456 f5ec - endif ; TMPMEMADDRESS > $1FFF 4457 f5ec endif ; EXTRADLMEMORY 4458 f5ec a0 .byte.b $1FFF 4451 f5ed -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5ed - else 4453 f5ed - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5ed -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5ed - endif 4456 f5ed - endif ; TMPMEMADDRESS > $1FFF 4457 f5ed endif ; EXTRADLMEMORY 4458 f5ed 40 .byte.b $1FFF 4451 f5ee -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5ee - else 4453 f5ee - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5ee -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5ee - endif 4456 f5ee - endif ; TMPMEMADDRESS > $1FFF 4457 f5ee endif ; EXTRADLMEMORY 4458 f5ee e0 .byte.b $1FFF 4451 f5ef -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5ef - else 4453 f5ef - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5ef -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5ef - endif 4456 f5ef - endif ; TMPMEMADDRESS > $1FFF 4457 f5ef endif ; EXTRADLMEMORY 4458 f5ef 80 .byte.b $1FFF 4451 f5f0 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5f0 - else 4453 f5f0 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5f0 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5f0 - endif 4456 f5f0 - endif ; TMPMEMADDRESS > $1FFF 4457 f5f0 endif ; EXTRADLMEMORY 4458 f5f0 20 .byte.b $1FFF 4451 f5f1 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5f1 - else 4453 f5f1 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5f1 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5f1 - endif 4456 f5f1 - endif ; TMPMEMADDRESS > $1FFF 4457 f5f1 endif ; EXTRADLMEMORY 4458 f5f1 c0 .byte.b $1FFF 4451 f5f2 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4452 f5f2 - else 4453 f5f2 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4454 f5f2 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4455 f5f2 - endif 4456 f5f2 - endif ; TMPMEMADDRESS > $1FFF 4457 f5f2 endif ; EXTRADLMEMORY 4458 f5f2 60 .byte.b $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 18 80 ZONE0ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 19 20 ZONE1ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 19 c0 ZONE2ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1a 60 ZONE3ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1b 00 ZONE4ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1b a0 ZONE5ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1c 40 ZONE6ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1c e0 ZONE7ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1d 80 ZONE8ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1e 20 ZONE9ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1e c0 ZONE10ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4464 f5f3 REPEND 4465 f5f3 TMPMEMADDRESS SET (((DLINDEX*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) 4466 f5f3 - ifconst EXTRADLMEMORY 4467 f5f3 - if TMPMEMADDRESS > $1FFF 4468 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4469 f5f3 - else 4470 f5f3 - if ((((DLINDEX+1)*WMEMSIZE)/WZONECOUNT)+WDLMEMSTART) > $1FFF 4471 f5f3 -TMPMEMADDRESS SET (TMPMEMADDRESS + $300) 4472 f5f3 - endif 4473 f5f3 - endif ; TMPMEMADDRESS > $1FFF 4474 f5f3 endif ; EXTRADLMEMORY 4475 f5f3 4476 f5f3 1f 60 ZONE11ADDRESS = TMPMEMADDRESS 4477 f5f3 4478 f5f3 DLINDEX SET DLINDEX + 1 4479 f5f3 REPEND 4480 f5f3 4481 f5f3 $1880 to $1fff used as zone memory, allowing 31 display objects per zone. 4482 f5f3 echo " ",[WDLMEMSTART],"to",[WDLMEMEND],"used as zone memory, allowing",[(DLLASTOBJ/5)]d,"display objects per zone." 4483 f5f3 4484 f5f3 DLHEIGHT 4485 f5f3 REPEAT WZONECOUNT 4486 f5f3 0f .byte.b (WZONEHEIGHT-1) 4485 f5f3 REPEND 4486 f5f4 0f .byte.b (WZONEHEIGHT-1) 4485 f5f4 REPEND 4486 f5f5 0f .byte.b (WZONEHEIGHT-1) 4485 f5f5 REPEND 4486 f5f6 0f .byte.b (WZONEHEIGHT-1) 4485 f5f6 REPEND 4486 f5f7 0f .byte.b (WZONEHEIGHT-1) 4485 f5f7 REPEND 4486 f5f8 0f .byte.b (WZONEHEIGHT-1) 4485 f5f8 REPEND 4486 f5f9 0f .byte.b (WZONEHEIGHT-1) 4485 f5f9 REPEND 4486 f5fa 0f .byte.b (WZONEHEIGHT-1) 4485 f5fa REPEND 4486 f5fb 0f .byte.b (WZONEHEIGHT-1) 4485 f5fb REPEND 4486 f5fc 0f .byte.b (WZONEHEIGHT-1) 4485 f5fc REPEND 4486 f5fd 0f .byte.b (WZONEHEIGHT-1) 4485 f5fd REPEND 4486 f5fe 0f .byte.b (WZONEHEIGHT-1) 4487 f5ff REPEND 4488 f5ff 4489 f5ff ; Provided under the CC0 license. See the included LICENSE.txt for details. 4490 f5ff 4491 f5ff ; a simple guard, than ensures the 7800basic code hasn't 4492 f5ff ; spilled into the encryption area... 2431 bytes left in the 7800basic reserved area. 4493 f5ff echo " ",($FF7E-*)d,"bytes left in the 7800basic reserved area." 4494 f5ff - if (*>$FF7D) 4495 f5ff - ERR ; abort the assembly 4496 f5ff endif 4497 f5ff ; Provided under the CC0 license. See the included LICENSE.txt for details. 4498 f5ff 4499 f5ff - ifconst DEV 4500 f5ff - ifnconst ZONEHEIGHT 4501 f5ff - echo "* the 4k 7800basic area has",[($FF7E - *)]d,"bytes free." 4502 f5ff - else 4503 f5ff - if ZONEHEIGHT = 8 4504 f5ff - echo "* the 4k 7800basic area has",[($FF7E - *)]d,"bytes free." 4505 f5ff - else 4506 f5ff - echo "* the 4k 7800basic area has",[($FF7E - *)]d,"bytes free." 4507 f5ff - endif 4508 f5ff - endif 4509 f5ff endif 4510 f5ff 4511 f5ff ; FF7E/FF7F contains the 7800basic crc checksum word 4512 f5ff 4513 f5ff ; FF80 - FFF7 contains the 7800 encryption key 4514 f5ff 4515 f5ff ifnconst bankswitchmode 4516 fff8 ORG $FFF8 4517 fff8 - else 4518 fff8 - ifconst ROM128K 4519 fff8 - ORG $27FF8 4520 fff8 - RORG $FFF8 4521 fff8 - endif 4522 fff8 - ifconst ROM144K 4523 fff8 - ORG $27FF8 4524 fff8 - RORG $FFF8 4525 fff8 - endif 4526 fff8 - ifconst ROM256K 4527 fff8 - ORG $47FF8 4528 fff8 - RORG $FFF8 4529 fff8 - endif 4530 fff8 - ifconst ROM272K 4531 fff8 - ORG $47FF8 4532 fff8 - RORG $FFF8 4533 fff8 - endif 4534 fff8 - ifconst ROM512K 4535 fff8 - ORG $87FF8 4536 fff8 - RORG $FFF8 4537 fff8 - endif 4538 fff8 - ifconst ROM528K 4539 fff8 - ORG $87FF8 4540 fff8 - RORG $FFF8 4541 fff8 - endif 4542 fff8 endif 4543 fff8 4544 fff8 4545 fff8 ff .byte.b $FF ; region verification. $FF=all regions 4546 fff9 f7 .byte.b $F7 ; high nibble: encryption check from $N000 to $FF7F. we only hash the last 4k for faster boot. 4547 fffa ; low nibble : N=7 atari rainbow start, N=3 no atari rainbow 4548 fffa 4549 fffa ;Vectors 4550 fffa 00 f0 .word.w NMI 4551 fffc 1d f5 .word.w START 4552 fffe 67 f0 .word.w IRQ 4553 10000