.export _draw_lorcha .import popax ; TODO: maybe replace position tables with mul40? see ; libsrc/atari/mul40.s, which is getting linked anyway ; because conio uses it. ; offset from start of screen for each ship position (0-9) lorcha_pos_lo: .byte <320, <328, <336, <344, <352 .byte <640, <648, <656, <664, <672 lorcha_pos_hi: .byte >320, >328, >336, >344, >352 .byte >640, >648, >656, >664, >672 ; Atari OS's pointer to start of screen RAM SAVMSC = $58 ; ZP working variables start at $d4, aka FR0 (floating point reg 0). mask = $d4 displacement = $d5 destptr = $d6 ; Lorcha (boat), a type of sailing vessel having a Chinese ; junk rig on a Portuguese or European style hull. ; Our lorcha is a 7x7 block of ATASCII characters. We're storing ; directly to screen RAM, so we use 'internal' codes. ; To edit the graphics, load up LORCHA.LST in atari800, with the H: ; device enabled, writable, set to current directory. Then edit the ; quoted strings in lines 10-70, and RUN the program. It will ; generate a new LORCHA.DAT, which must be 49 bytes long (so don't ; change the lengths of the strings in the BASIC code!) lorcha_data: .incbin "LORCHA.DAT" ; void __fastcall__ draw_lorcha(int which, int displacement, int mask); _draw_lorcha: sta mask ; stash mask (0 = normal, $80 = inverse) jsr popax ; get displacement (0 = whole ship, 1..6 = sinking, 7 = blank) sta displacement jsr popax ; which ship position? tax ; setup pointer to screen offset of upper left of ship lda lorcha_pos_lo,x clc adc SAVMSC sta destptr lda lorcha_pos_hi,x clc adc SAVMSC+1 sta destptr+1 ; first, draw any blank lines ldx displacement ; are there any? beq shiplineloop ; no, draw ship blanklineloop: lda #0 ; screen code for space ;ora mask ; apply mask ; don't need this here ldy #6 ; ship is 7 columns wide (we count 6 to -1) blankcolloop: sta (destptr),y dey bpl blankcolloop jsr bump_pointer ; add 40 (1 line) to dest pointer. dex bne blanklineloop ; X is now 0, however we got here. shiplineloop: lda displacement cmp #7 beq done ldy #0 shipcolloop: lda lorcha_data,x eor mask sta (destptr),y iny inx cpy #7 bne shipcolloop jsr bump_pointer inc displacement clc bcc shiplineloop done: rts bump_pointer: lda destptr clc adc #40 sta destptr lda destptr+1 adc #0 sta 215 rts