<pre>
;; Dissassembled and commented from MCPEN.BIN
org 09c40h
or 0c0h ;; AY control select register.
out (c),a
out (c),a ;; BUG. This should set AY control Should be out (c),c to 0 to also be compatible with Plus.
inc b
ld a,092h
out (c),a
push bc
ld bc,0f649h ;; AY control read from register and select keyboard line 9 (joystick)
out (c),c
out (c),c ;; BUG? No need to do this twice.
ld (0a410h),hl ;; detected 'position' or 'ffff' for not detected
pop bc
;; BUG: For compatibility with Plus this should set AY control to 0 via Port F6xx.
ld a,082h
out (c),a
dec b
out (c),c;; Set AY control inactive.
ei
ret
ret
;; HL = HL/DE
sub_9c94:
ld a,h
ld c,l
ld b,010h;; 16 bits.
ld hl,00000h
l9cdbh:
ret
;; HL = HL * DE
sub_9caeh:
ld a,l
ld c,h
ld b,010h;; 16 bits
ld hl,00000h
l9cf5h:
;; detected.
ld de,00002h
call sub_9c94h;; HL = HL/DE
ld de,00064h
call sub_9caeh;; HL = HL*DE
ld de,00084h
call sub_9c94h;; HL = HL/DE
ex de,hl
ld hl,0018fh
ld a,0ffh
cp h
jr nz,l9ddahsub_9d9ah
ld de,00000h
ld hl,00014h
ld (0a410h),hl
ret
l9ddahsub_9d9ah:
pop bc
ld (0a410h),hl
push de
ld de,00002h
call sub_9c94h;; HL = HL/DE
pop de
push hl
ex de,hl
ld de,(0a416h)
call sub_9c94h;; HL = HL/DE
ex de,hl
pop hl
call sub_09dbeh
call 0bbc0h ;; gra move absolute
sub_9e52h:
call sub_09ed2h
call sub_09de6h
call 0bb1eh ;; km test key
ret z
jp l9e52hsub_9e52h
l9ea9h:
cp h
ret nz
l9ef5h:
pop de
ret
sub_9eb7h:
ld hl,(0a41ah)
ld de,(0a412h)
l9efeh:
and a
sbc hl,de
ret z
jp p,09ecbhl9ecbh
ld hl,l9f15h
jp 09ecehl09eceh l9ecbh: ld hl,09ed2hsub_9ed2hl9f0ehl9eceh:
ld (l9e52h+1),hl
ret
sub_9ed2h:
call sub_9e98h
l9f15h:
ld de,0ffech
ld hl,00000h
call 0bbc3h ;; gra move relative
ld bc,(0a420h)
l9f22h:
push bc
ld de,00000h
ld a,0ffh
cp h
jp nz,l9efehsub_9efehsub_9ef5h:
ld hl,(0a422h)
ld (0a410h),hl
jp l9d9ahsub_9d9ah sub_9efeh:
ld (0a422h),hl
ld de,(0a416h)
ld (0a410h),hl
ret
sub_9f82h:
call sub_9e98h
ld bc,(0a420h)
ld a,0ffh
cp h
jp z,l9ef5hsub_9ef5h
ld (0a422h),hl
ld de,(0a416h)
call 0bbc3h ;; gra move relative
jp l9f0eh
nop nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nopdb 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nopla050h: nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop;; screen dump to printer.
sub_0a028h:
ld a,013h
sub_a050h:
ld a,000h
ld (0a12ch),a;; accumulated pixels.
ld de,(0a12dh)
call sub_a10dh;; store current graphics position
call 0bbf0h ;; gra test absolute
ld de,00001h
call sub_a11dh;; get pixel
ld de,00002h
call sub_a11dh;; get pixel
ld de,00004h
call sub_a11dh;; get pixel
ld de,00008h
call sub_a11dh;; get pixel
ld de,00010h
call sub_a11dh;; get pixel
ld de,00020h
call sub_a11dh;; get pixel
ld de,00040h
call sub_a0ffh;; get pixel
la0c9h:
call 0bd2eh ;; mc busy printer
jr c,la0c9h
call 0bd28h ;; mc reset printer
ld a,01bh ;; ESC
call 0bd2bh ;; mc print char
ld a,04bh ;; K
call 0bd2bh ;; mc print char
ld a,000h ;; number of columns low byte
call 0bd2bh ;; mc print char
ld a,(0a133h)
bit 0,a
jr z,la0b4h
ld a,002h ;; number of columns high byte?
call 0bd2bh ;; mc print char
ld a,(0a12ch);; pixel data
call 0bd2bh ;; mc print char
jr la0f9h
la0b4h:
ld a,001h ;; number of columns high byte?
call 0bd2bh ;; mc print char
la0f9h:
ld a,(0a12ch);; pixel data
call 0bd2bh ;; mc print char
call sub_a115h
inc hl
cp 090h
jp nz,sub_a050h
ld a,00ah ;; next line
call 0bd2bh ;; mc print char
ld a,02fh ;; 47 - space
call 0bb1eh ;; km test key
ret nz
ret
;; accumulate pixels
sub_a0ffh:
ld b,a
call 0bb99h ;; txt get paper
cp b ;; was the colour read the same as the paper?
ret z
;; any pixel which is not the same as the paper will be considered foreground
;; and the printer will draw a dot. Any pixel the same as the paper will
;; be considered background and no dot is drawn by the printer.
;; pixel is set to foreground. accumulate it into the pixel data so far
ld hl,(0a12ch)
add hl,de
sub_a11dh:
call sub_a0ffh;; accumulate a pixel for printing. call sub_a115h;; get current X/Y graphics position inc de ;; increment X to next pixel accross screen.
inc de
inc de call sub_a10dh;; set current X/Y graphics position
call 0bbf0h ;; gra test absolute
ret
la10ch: nop add adb 00h,h ld (bc)84h,02h,00h,00h,a0eh,00h,00h,00h nop nop ld cdb 0,0,0,0,0,0,000h0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop
sub_a154h:
call 0bc11h ;; scr get mode
ld a,b
la1aah:
ld (0a254hdata_a254),a
call 0bbc6h ;; gra ask cursor
ld (0a250hdata_a250),hl ld (0a250hdata_a250+2),de
la1b7h:
call 0bb99h ;; txt get paper
ld (0a1f9h),a
ld bc,00000h
ld (0a24chdata_a24c),bc ld (0a24ehdata_a24e),bc
call sub_a210
ld a,02fh ;; 47 - space
call 0bb1eh ;; km test key
ret nz
ld hl,(0a24ehdata_a24e)
inc hl
inc hl
ld hl,00000h
la1deh:
ld (0a24ehdata_a24e),hl
ld bc,05398h
add hl,bc
ld (0a1aah),hl
ld de,(055e0h)
ld hl,(0a24ehdata_a24e)
sub_a1efh:
ld bc,057e4h
la1f9h:
ld (la257h),hl
ld (0a255hdata_a255),de
ld bc,00000h
ld a,(0a254hdata_a254)
ld c,a
ex de,hl
dec hl
call sub_a1efh
ld hl,(0a24ehdata_a24e) ld de,(0a24chdata_a24c)
inc hl
inc hl
cp 000h
jr nz,la248h
ld (0a250hdata_a250),hl ld (0a250hdata_a250+2),de
push bc
call sub_0a210h
pop bc
la248h:
ld hl,(0a257hdata_a257) ld de,(0a255hdata_a255)
ret
sub_a210:
ld hl,(0a250hdata_a250) ld de,(0a250hdata_a250+2)
call 0bbeah ;; gra plot absolute
ld hl,(0a24chdata_a24c)
inc hl
inc hl
ld hl,00000h
la267h:
ld (0a24chdata_a24c),hl
ld bc,05398h
add hl,bc
ld de,(0a250hdata_a250+2)
ld (0a237h),hl
ld (05648h),de
ld hl,(0a24chdata_a24c)
ld bc,057e4h
add hl,bc
ld de,(0a250hdata_a250)
ld (0a249),hl
ld (05a94h),de
ret
la24ch:
or b
ld (bc),a
ld c,b
ld (bc),a
cp (hl)
nop
jr nz,la295h
inc b
jr nz,$+3
cp h
;;Data areadata_a24c: defw 02b0hdata_a24e: defw 0248hdata_a250: defw 0behdata_a252: defw 0120hdata_a254: defb 04hdata_a255: defw 0120hdata_a257: defw 0bch end</pre>
[[Category:Source code]]