;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ;Û Û ;Û GRAPHICS PROCEDURES Û ;Û Û ;Û These procedures are not optimized. Û ;Û Û ;Û NOTE: '&' - this char can use only with PROC/PROCS and MACRO. Û ;Û Û ;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ;----------------------------------------------------------------------------- ; Show the cursor. (only in text mode) ;----------------------------------------------------------------------------- Cursor&ON PROC LDA 87 BNE _cur_on_ LDA 93 LDY #0 EOR #%10000000 STA (94),Y INY STY _is_cursor_ _cur_on_: RTS IfNDef _is_cursor_ _is_cursor_ db 1 endndef ENDP ;----------------------------------------------------------------------------- ; Hide the cursor. (only in text mode) ;----------------------------------------------------------------------------- CURSOR&OFF PROC lda 87 bne _cur_off_ lda 93 ldy #0 sta (94),y sty _is_cursor_ _cur_off_: rts ifndef _is_cursor_ _is_cursor_ db 1 endndef ENDP ;----------------------------------------------------------------------------- ; Set text or graphics mode. ; in: A - Number of mode 0-15 (+16 window, +32 don't clear memory) ;----------------------------------------------------------------------------- Graphics PROC A tax and #%00010000 sta _is_win_ txa and #%00001111 sta 87 cmp #9 bmi _grap0_ cmp #12 bpl _grap0_ asl 623 asl 623 ROR @ ror 623 ror @ ror 623 _grap0_: ; txa ; eor #16 ;What with WINDOW ??? ; sta $2B ;This is sytem graphics but I don't how to active ; jsr $EF8E ;window ? txa sta 928+11 and #%11110000 ora #%00001100 sta 928+10 lda #3 sta 928+2 sta 928+8 lda #255 sta 928 ldx <_sname_ LDY >_sname_ stx 928+4 sty 928+5 ldx #96 jsr 58454 lda #1 STA _is_graph_ jmp _istart_ ifndef _istart_ _istart_: pha TXA pha tya pha ldy #192 clc _is0_: lda 88 adc _adrl_-1,y sta _adrlo_-1,y lda 89 ADC _adrh_-1,Y sta _adrhi_-1,y dey bne _is0_ lda #1 sta _is_tab_ PLA tay pla tax pla rts endndef ifndef _is_graph_ _is_graph_ db 0 endndef ifndef _is_win_ _is_win_ db 0 endndef ifndef _AdrH_ _AdrH_ DB 0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2 db 3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,5,6 db 6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,9,9 db 9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12 db 12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,15,15,15,15 db 15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18 DB 18,18,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21 db 21,22,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,24,24,24 db 25,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,27 db 28,28,28,28,28,28,29,29,29,29,29,29 _AdrL_: db 0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248 db 32,72,112,152,192,232,16,56,96,136,176,216,0,40,80,120,160,200,240,24 db 64,104,144,184,224,8,48,88,128,168,208,248,32,72,112,152,192,232,16,56 db 96,136,176,216,0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88 DB 128,168,208,248,32,72,112,152,192,232,16,56,96,136,176,216,0,40,80,120 db 160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248,32,72,112,152 db 192,232,16,56,96,136,176,216,0,40,80,120,160,200,240,24,64,104,144,184 db 224,8,48,88,128,168,208,248,32,72,112,152,192,232,16,56,96,136,176,216 db 0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248 db 32,72,112,152,192,232,16,56,96,136,176,216 _is_tab_ db 0 ;=0 m¢wi, ¾e tablice _AdrLo_ i _AdrHi_ nie s¥ zaktualizowane _AdrLo_ Org *+192 _AdrHi_ org *+192 endndef ifndef _sname_ _sname_ db c'S:',155 endndef ENDP ;----------------------------------------------------------------------------- ; Put the pixel on the screen. ; in: AX - coordinate X. ; Y - coordinate Y. ;----------------------------------------------------------------------------- Plot PROC AX,Y stx 85 sta 86 sty 84 _plot00_: lda _is_tab_ bne _plota_ jsr _istart_ _plota_: lda 87 cmp #15 bne _plot8_ _plot15_: txa lsr @ lsr @ clc adc _adrlo_,Y sta _paddr_ lda #0 adc _adrhi_,y sta _paddr_+1 _plot15_0_: lda 763 and #%00000011 tay txa and #%00000011 tax lda _CTab_,y and _MTab_,x sta 90 ldy #0 lda (_paddr_),y and _STab_,x ora 90 sta (_paddr_),y _plot_end_: ldx 85 lda 86 ldy 84 stx 91 sta 92 sty 90 rts _plotmax_: ldx 85 ldy 84 jmp _plot00_ _plot8_: cmp #7 BEQ _plot15_ cmp #8 bne _plot9_ lda 86 lsr @ db $A7,85 ROR @ lsr @ LSR @ clc adc _adrlo_,y sta _paddr_ lda #0 adc _adrhi_,y sta _paddr_+1 _plot8_0_: lda 763 and #%00000001 tay txa and #%00000111 TAX LDA _CTab8_,Y and _MTab8_,x sta 90 ldy #0 lda (_paddr_),y and _STab8_,x ORA 90 sta (_paddr_),y JMP _plot_end_ _plot14s_: jmp _plot14_ _plot3s_: jmp _plot3_ _plot4s_: jmp _plot4_ _plot5s_: jmp _plot5_ _plot9_: cmp #14 beq _plot14s_ cmp #3 beq _plot3s_ cmp #4 beq _plot4s_ cmp #5 BEQ _plot5s_ cmp #6 beq _plot14s_ cmp #9 bne _plottext_ txa LSR @ clc ADC _adrlo_,Y sta _paddr_ lda #0 adc _adrhi_,y sta _paddr_+1 lda 763 and #%00001111 tay txa and #%00000001 tax lda _CTab9_,y and _MTab9_,x sta 90 LDY #0 lda (_paddr_),y AND _STab9_,X ora 90 sta (_paddr_),y jmp _plot_end_ _plottext_: LDA #0 sta _eol_ _plotex2_: txa ldx 87 beq _plotex0_ cpx #12 beq _plotex0_ cpx #13 beq _plotex0_ asl @ ;*2 _plotex0_: clc adc _adrl_,y STA _paddr_ LDA #0 adc _adrh_,y sta _paddr_+1 lda 87 beq _plotex1_ CMP #12 beq _plotex1_ CMP #13 beq _plotex1_ jsr _lsr_plot_ _plotex1_: jsr _set_plot_ lda 763 ldy #0 ldx _eol_ bne _move_prin_ sta (_paddr_),y ;cz©˜† odpowiedzialna za przeniesienie kursora _move_prin_: ldx 94 LDA 95 CMP _paddr_+1 bne _prin1e_ cpx _paddr_ beq _prin1f_ _prin1e_: LDA 93 sta (94),y LDA _paddr_ sta 94 lda _paddr_+1 sta 95 _prin1f_: lda (94),y sta 93 eor #%10000000 sta (94),y jmp _plot_end_ _plot33_: clc adc _adrl_,y STA _paddr_ LDA #0 adc _adrh_,y sta _paddr_+1 jmp _lsr_plot_ _plot3_: txa JSR _plot33_ jsr _lsr_plot_ jsr _set_plot_ jmp _plot15_0_ _plot4_: txa lsr @ jsr _plot33_ jsr _lsr_plot_ jsr _set_plot_ jmp _plot8_0_ _plot5_: TXA LSR @ jsr _plot33_ jsr _set_plot_ jmp _plot15_0_ _plot14_: txa LSR @ lsr @ jsr _plot33_ jsr _set_plot_ jmp _plot8_0_ _lsr_plot_: lsr _paddr_+1 ror _paddr_ rts _set_plot_: clc lda 88 ADC _paddr_ STA _paddr_ lda 89 adc _paddr_+1 sta _paddr_+1 rts ifndef _istart_ _istart_: pha txa pha tya pha ldy #192 clc _is0_: lda 88 adc _adrl_-1,y sta _adrlo_-1,y lda 89 adc _adrh_-1,y sta _adrhi_-1,y DEY BNE _is0_ lda #1 sta _is_tab_ pla tay PLA tax PLA rts endndef _paddr_=51 ; (2) circle u¾ywa kom¢rek, a¾ do 50-tej wˆ¥cznie ifndef _eol_ _eol_ db 0 endndef ; tablice z kolorami IfNDef _CTab_ _CTab_ DB B(0),B(%01010101),B(%10101010),B(%11111111) EndNDef _CTab8_ DB B(0),B(255) _CTab9_ DB B(0),B(%00010001),B(%00100010),B(%00110011) DB B(%01000100),B(%01010101),B(%01100110),B(%01110111) DB B(%10001000),B(%10011001),B(%10101010),B(%10111011) DB B(%11001100),B(%11011101),B(%11101110),B(%11111111) ; tablice do skasowania danego punktu tˆa IfNDef _STab_ _STab_ DB 63,207,243,252 EndNDef _STab8_ DB 127,191,223,239,247,251,253,254 _STab9_ DB 15,240 ; tablice dodatkowe do otrzymania ostatecznego koloru! IfNDef _MTab_ _MTab_ DB 192,48,12,3 EndNDef _MTab8_ DB 128,64,32,16,8,4,2,1 _MTab9_ DB 240,15 IfNDef _AdrH_ _AdrH_ DB 0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2 DB 3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,5,6 DB 6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,9,9 DB 9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12 DB 12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,15,15,15,15 DB 15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18 db 18,18,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21 db 21,22,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,24,24,24 db 25,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,27 db 28,28,28,28,28,28,29,29,29,29,29,29 _AdrL_: db 0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248 db 32,72,112,152,192,232,16,56,96,136,176,216,0,40,80,120,160,200,240,24 db 64,104,144,184,224,8,48,88,128,168,208,248,32,72,112,152,192,232,16,56 db 96,136,176,216,0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88 db 128,168,208,248,32,72,112,152,192,232,16,56,96,136,176,216,0,40,80,120 db 160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248,32,72,112,152 DB 192,232,16,56,96,136,176,216,0,40,80,120,160,200,240,24,64,104,144,184 db 224,8,48,88,128,168,208,248,32,72,112,152,192,232,16,56,96,136,176,216 db 0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248 db 32,72,112,152,192,232,16,56,96,136,176,216 _is_tab_ db 0 ;=0 m¢wi, ¾e tablice _AdrLo_ i _AdrHi_ nie s¥ zaktualizowane _AdrLo_ org *+192 _AdrHi_ org *+192 endndef ENDP ;----------------------------------------------------------------------------- ; Set color. ; in: A - number of color. ;----------------------------------------------------------------------------- Color PROC A sta 763 rts ENDP ;----------------------------------------------------------------------------- ; Get color from the point X,Y. ; in: AX - coordinate X. ; Y - coordinate Y. ; out: A - number of color. ;----------------------------------------------------------------------------- Locate PROC AX,Y stx _xd1_ sta _xd1_+1 sty _yd1_ lda 87 cmp #15 beq _locate15_ cmp #7 beq _locate15_ lda 763 ;zachowaj kolor sta _pom_loc_ lda #7 sta 928+2 ldy #1 sty 928+8 dey sty 928+9 ldx <_locbuff_ ldy >_locbuff_ stx 928+4 sty 928+5 ldx #96 jsr 58454 lda _pom_loc_ STA 763 ;zachowaj kolor lda _locbuff_ rts _locate15_: ;tylko tryb 15 i 7 lda _is_tab_ bne _loc1_ jsr _istart_ _loc1_: lda _adrlo_,y sta _ad0_ lda _adrhi_,y sta _ad0_+1 txa lsr @ lsr @ tay txa and #3 tax _loc15_: txa and #3 tax lda _loctab0_,x sta _loc2_+1 lda _loctab1_,x sta _loc2_+2 _loc2_: jmp * _l00_: lda (_ad0_),y rol @ rol @ rol @ and #%00000011 rts _l01_: lda (_ad0_),y and #%00110000 lsr @ lsr @ lsr @ lsr @ rts _l02_: lda (_ad0_),y AND #%00001100 lsr @ lsr @ rts _l03_: lda (_ad0_),y and #%00000011 rts _loctab0_ db <_l00_,<_l01_,<_l02_,<_l03_ _loctab1_ db >_l00_,>_l01_,>_l02_,>_l03_ ifndef _xd1_ _xd1_=85 ;(2) _yd1_=84 _ad0_=32 ;(2) endndef _locbuff_ db 0 _pom_loc_ db 0 ifndef _istart_ _istart_: pha txa pha tya pha ldy #192 clc _is0_: lda 88 adc _adrl_-1,y sta _adrlo_-1,y lda 89 adc _adrh_-1,y sta _adrhi_-1,y dey bne _is0_ lda #1 sta _is_tab_ pla tay pla tax pla rts _is_tab_ db 0 ;=0 m¢wi, ¾e tablice _AdrLo_ i _AdrHi_ nie s¥ zaktualizowane endndef ifndef _AdrH_ _AdrH_ DB 0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,2 db 3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,5,6 db 6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,9,9 db 9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12 db 12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,15,15,15,15 db 15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18 db 18,18,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21 db 21,22,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,24,24,24 db 25,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,27 db 28,28,28,28,28,28,29,29,29,29,29,29 _AdrL_: db 0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248 db 32,72,112,152,192,232,16,56,96,136,176,216,0,40,80,120,160,200,240,24 db 64,104,144,184,224,8,48,88,128,168,208,248,32,72,112,152,192,232,16,56 db 96,136,176,216,0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88 db 128,168,208,248,32,72,112,152,192,232,16,56,96,136,176,216,0,40,80,120 db 160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248,32,72,112,152 db 192,232,16,56,96,136,176,216,0,40,80,120,160,200,240,24,64,104,144,184 db 224,8,48,88,128,168,208,248,32,72,112,152,192,232,16,56,96,136,176,216 db 0,40,80,120,160,200,240,24,64,104,144,184,224,8,48,88,128,168,208,248 db 32,72,112,152,192,232,16,56,96,136,176,216 _AdrLo_ org *+192 _AdrHi_ org *+192 endndef ENDP ;----------------------------------------------------------------------------- ; Set color for one of atari's registers. ; in: Y - number of register. ; X - number of color. ; A - number of shade. ;----------------------------------------------------------------------------- SetColor PROC Y,X,A and #%00001111 sta 32 txa asl @ asl @ asl @ asl @ adc 32 sta 32 ldx 87 cpx #9 beq _setc1_ cpx #10 beq _setc1_ cpx #11 BEQ _setc1_ tya and #15 cmp #11 bcc _setc000_ sbc #11-1 ;bo C=1 _setc000_: cmp #6 bcc _setc00_ sbc #6-1 ;bo C=1 _setc00_: tay cpy #0 bne _setc0_ ldy #5 _setc0_: lda 32 sta 707,y rts _setc1_: tya and #15 cmp #10 bcc _setc22_ clc sbc #9 _setc22_: tay cpy #0 bne _setc2_ ldy #9 _setc2_: lda 32 sta 703,y rts ENDP ;----------------------------------------------------------------------------- ; Set position of cursor. ; in: ((85)) - coordinate X. ; (84) - coordinate Y. ;----------------------------------------------------------------------------- Position PROC ((85)),(84) rts ENDP ;----------------------------------------------------------------------------- ; Paint area. (only in 7 and 15 mode) ; in: X - coordinate X. ; Y - coordinate Y. ; A - color. ;----------------------------------------------------------------------------- Paint PROC X,Y,A cmp #255 bne _paint01_ ;nie ma podanego koloru! lda #0 sta _paint111_+1 sta _paint3333_+1 sta _paint666_+1 sta _paint99_+1 sta _up00_+1 sta _up01_+1 sta _up02_+1 sta _up03_+1 sta _dp00_+1 sta _dp01_+1 sta _dp02_+1 sta _dp03_+1 lda #240 ;BEQ sta _paint111_+2 sta _paint3333_+2 sta _paint666_+2 sta _paint99_+2 sta _up00_+2 sta _up01_+2 sta _up02_+2 sta _up03_+2 sta _dp00_+2 sta _dp01_+2 sta _dp02_+2 sta _dp03_+2 jmp _paintstart_ _paint01_: ;jest podany kolor ! sta _paint111_+1 sta _paint3333_+1 sta _paint666_+1 sta _paint99_+1 sta _up00_+1 sta _up01_+1 sta _up02_+1 sta _up03_+1 sta _dp00_+1 STA _dp01_+1 sta _dp02_+1 sta _dp03_+1 lda #208 ;BNE sta _paint111_+2 sta _paint3333_+2 sta _paint666_+2 sta _paint99_+2 sta _up00_+2 sta _up01_+2 sta _up02_+2 sta _up03_+2 sta _dp00_+2 sta _dp01_+2 sta _dp02_+2 sta _dp03_+2 _paintstart_: stx _xd0_ stx _pxd0_ sty _yd0_ jsr _count_addr_ lda _ad0_ sec sbc <120 sta _ad0_ pha lda _ad0_+1 sbc >120 sta _ad0_+1 pha lda 763 and #3 sta _fillcol_ tax lda _CTab_,x sta _paintcol_ jsr _paint15_ jsr _upaint15_ ldx _pxd0_ pla sta _ad0_+1 pla sta _ad0_ jmp _dpaint15_ _paint15_: ;aktualizuj adresy! ldy _ad0_ sty _paint1_+1 sty _paint11_+1 sty _paint33_+1 sty _paint333_+1 sty _paint6_+1 sty _paint66_+1 sty _paint88_+1 sty _paint888_+1 ldy _ad0_+1 sty _paint1_+2 sty _paint11_+2 sty _paint33_+2 sty _paint333_+2 sty _paint6_+2 sty _paint66_+2 sty _paint88_+2 sty _paint888_+2 ;przygotuj maski ldx #3 _paintmsk_: lda _paintcol_ and _MTab_,x sta 36,x dex bpl _paintmsk_ ldy #120 lda _paintcol_ jmp _paint11_ _paint1_: sta $FFFF,y dey _paint11_: ldx $FFFF,y _paint111_: cpx #0 beq _paint1_ ldx #3 cpy #120 bne _paint4_ lda _xd0_ and #3 tax JMP _paint4_ _paint33_: lda $FFFF,y and _STab_,x ora 36,x _paint333_: sta $FFFF,y dex _paint4_: jsr _loc15_ _paint3333_: cmp #0 beq _paint33_ cpy #120 bne _paint5_ ldy #120 lda _xd0_ and #3 tax cpx #3 beq _paint7_ jmp _paint_8_ _paint5_: ldy #120 lda _paintcol_ jmp _paint7_ _paint6_: sta $FFFF,y _paint7_: iny _paint66_: ldx $FFFF,y _paint666_: cpx #0 beq _paint6_ ldx #0 jmp _paint9_ _paint88_: lda $FFFF,y and _STab_,x ora 36,x _paint888_: sta $FFFF,y _paint_8_: inx CPX #4 beq _paint5_ _paint9_: jsr _loc15_ _paint99_: cmp #0 beq _paint88_ rts ;wypeˆnij w g¢r©! _upaint15_: lda _ad0_ sec sbc <40 sta _ad0_ lda _ad0_+1 sbc >40 sta _ad0_+1 ldy #120 lda (_ad0_),y _up00_: cmp #0 beq _uskip1_ dey lda (_ad0_),y _up01_: cmp #0 beq _uskip11_ lda _xd0_ and #3 tax ldy #120 lda (_ad0_),y jsr _loc15_ _up02_: cmp #0 beq _uskip1_ _uloop_: jmp _upai1_ _upai0_: lda (_ad0_),y and _STab_,x ora 36,x sta (_ad0_),y _upai1_: dex bpl _upai2_ dey ldx #3 _upai2_: lda (_ad0_),y jsr _loc15_ _up03_: cmp #0 beq _upai0_ tya clc adc #40 tay lda (_ad0_),y _upai22_: ldy #120 lda _xd0_ and #3 tax bne _upai4_ ldx #4 lda _ad0_ bne _upai3_ dec _ad0_+1 _upai3_: dec _ad0_ _upai4_: dex dec _xd0_ lda _ad0_ sec sbc <40 sta _ad0_ lda _ad0_+1 sbc >40 sta _ad0_+1 jmp _upai1_ _uskip11_: lda _ad0_ bne _upspr0_ dec _ad0_+1 _upspr0_: dec _ad0_ LDA _xd0_ ora #3 sta _xd0_ _uskip1_: jsr _paint15_ jmp _upaint15_ ;wypeˆnij w d¢ˆ! _dpaint15_: lda _ad0_ clc adc <40 sta _ad0_ lda _ad0_+1 adc >40 sta _ad0_+1 ldy #120 lda (_ad0_),y _dp00_: cmp #0 beq _dskip1_ ldy #120-1 lda (_ad0_),y _dp01_: cmp #0 beq _dskip11_ lda _xd0_ and #3 tax jsr _loc15_ _dp02_: cmp #0 beq _dskip1_ cpx #3 bne _dskip2_ inc _xd0_ ldx #255 inc _ad0_ bne _dskip2_ inc _ad0_+1 _dskip2_: inx jsr _loc15_ _dp03_: CMP #0 beq _dskip1_ rts _dskip11_: dec _ad0_ bne _dpspr0_ dec _ad0_+1 _dpspr0_: dec _ad0_ lda _xd0_ ora #3 sta _xd0_ _dskip1_: jsr _paint15_ jmp _dpaint15_ ;zmienne _ispaint_ db 0 _fillcol_ db 0 ifndef _ad0_ _ad0_=32 ;(2) endndef _pxd0_=34 ifndef _xd0_ _xd0_=91 ;(2) _yd0_=90 endndef _paintcol_ db 0 ifndef _CTab_ _CTab_ db b(0),b(%01010101),b(%10101010),b(%11111111) endndef ifndef _MTab_ _MTab_ À0 ' endndef ifndef _STab_ _STab_ ?Ïóü' endndef LOCATE 0,0 ; wylicza dokˆadny adres na podst. x,y ifndef _count_addr_ _count_addr_: ;mno¾enie _yd0_*32+_yd0_*8 lda _yd0_ lsr @ lsr @ lsr @ tay LSR @ lsr @ sta _ad0_+1 lda _yd0_ asl @ asl @ asl @ sta _ad0_ asl @ asl @ clc adc _ad0_ sta _ad0_ tya adc _ad0_+1 sta _ad0_+1 ;dodanie _xd0_/4 lda _xd0_ lsr @ lsr @ clc adc _ad0_ sta _ad0_ bcc _counta1_ inc _ad0_+1 _counta1_: lda 88 clc adc _ad0_ sta _ad0_ lda 89 adc _ad0_+1 sta _ad0_+1 rts endndef ENDP ;----------------------------------------------------------------------------- ; Fill area. ; in: ((_fill_x)) - coordinate X. ; (_fil_y_) - coordinate Y. ; A - color. ;----------------------------------------------------------------------------- Fill PROC ((_fill_x_)),(_fill_y_),A cmp #255 bne _fillst_ lda #0 sta _fcc0_+1 STA _fcc1_+1 sta _fcc2_+1 sta _fcc3_+1 sta _fcc4_+1 lda #240 ;BEQ sta _fcc0_+2 sta _fcc1_+2 sta _fcc2_+2 sta _fcc3_+2 lda #208 ;BNE sta _fcc4_+2 jmp _fistart_ _fillst_: and #3 sta _fcc0_+1 sta _fcc1_+1 sta _fcc2_+1 sta _fcc3_+1 sta _fcc4_+1 lda #208 ;BNE sta _fcc0_+2 sta _fcc1_+2 sta _fcc2_+2 sta _fcc3_+2 lda #240 ;BEQ sta _fcc4_+2 _fistart_: lda #0 sta _fill_1_ jsr 63178 jsr 61839 _fcc0_: cmp #0 beq _fi00_ rts _fi00_: lda _fill_x_ bne _fi1_ dec _fill_x_+1 _fi1_: dec _fill_x_ _fi0_: jsr 63178 jsr 61839 _fcc1_: CMP #0 beq _fi00_ _fi2_: inc _fill_x_ bne _fi3_ inc _fill_x_+1 _fi3_: lda #0 sta _fill_2_ sta _fill_3_ _fia_: dec _fill_y_ jsr 61839 sta _fill_4_ inc _fill_y_ inc _fill_y_ jsr 61839 sta _fill_5_ dec _fill_y_ lda _fill_4_ _fcc2_: cmp #0 beq _fi4_ lda #0 sta _fill_2_ beq _fi5_ _fi4_: lda _fill_2_ bne _fi5_ lda #1 sta _fill_2_ ldy _fill_1_ lda _fill_x_ sta _bufforfill_,y iny lda _fill_x_+1 sta _bufforfill_,y iny dec _fill_y_ lda _fill_y_ sta _bufforfill_,y iny inc _fill_y_ sty _fill_1_ _fi5_: lda _fill_5_ _fcc3_: CMP #0 beq _fi6_ lda #0 sta _fill_3_ beq _fi7_ _fi6_: lda _fill_3_ bne _fi7_ lda #1 sta _fill_3_ ldy _fill_1_ lda _fill_x_ sta _bufforfill_,y iny lda _fill_x_+1 sta _bufforfill_,y iny inc _fill_y_ lda _fill_y_ sta _bufforfill_,y iny dec _fill_y_ sty _fill_1_ _fi7_: jsr 61898 inc _fill_x_ bne _fi8_ inc _fill_x_+1 _fi8_: jsr 63178 jsr 61839 _fcc4_: cmp #0 bne _fi9_ jmp _fia_ _fi9_: ldy _fill_1_ dey lda _bufforfill_,y sta _fill_y_ dey lda _bufforfill_,y sta _fill_x_+1 dey lda _bufforfill_,y sta _fill_x_ sty _fill_1_ CPY #253 beq _fin_ jmp _fi0_ _fin_: rts _bufforfill_ org *+256 _fill_1_=32 _fill_2_=33 _fill_3_=34 _fill_4_=35 _fill_5_=36 _fill_x_=85 ;(2) _fill_y_=84 ifndef _xd1_ _xd1_=85 ;(2) _yd1_=84 endndef ENDP ;----------------------------------------------------------------------------- ; Set address of active screen. ; in: YX - address. ;----------------------------------------------------------------------------- Screen PROC YX stx 88 sty 89 ldx #0 stx _is_graph_ rts ifndef _is_graph_ _is_graph_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Set address of visible screen. ; in: YX - address. ;----------------------------------------------------------------------------- Swap PROC YX stx 34 sty 35 ldx 560 ldy 561 stx 32 sty 33 ldy #255 _SwapLoop_: iny lda (32),y CPY #255 beq _SwapRTS_ tax and #%00001111 beq _SwapLoop_ txa and #%01000000 beq _SwapLoop_ iny lda 34 sta (32),y iny lda 35 sta (32),y _SwapRTS_: rts ENDP ;----------------------------------------------------------------------------- ; Clear screen. ; in: A - color. ;----------------------------------------------------------------------------- Cls PROC A sta _color_cls_ ldx _is_win_ bne _cls1_ ldx <_clstab1_ ldy >_clstab1_ jmp _cls2_ _cls1_: ldx <_clstab2_ ldy >_clstab2_ _cls2_: stx 32 sty 33 lda 87 asl @ tay lda (32),y sta 34 iny lda (32),y sta 35 ldx 88 ldy 89 stx 32 sty 33 ldy #0 LDA _color_cls_ _cls3_: sta (32),y inc 32 bne _cls4_ inc 33 _cls4_: ldx 34 bne _cls5_ ldx 35 beq _cls6_ dec 35 _cls5_: dec 34 jmp _cls3_ _cls6_: lda 87 bne _clsskip_ lda (94),y sta 93 eor #%10000000 sta (94),y _clsskip_: rts ifndef _is_win_ _is_win_ db 0 endndef ifndef _color_cls_ _color_cls_ db 0 endndef _clstab1_: dw 960,480,240,240,480,960,1920 dw 3840,7680,7680,7680,7680 dw 960,480,3840,7680 _clstab2_: dw 960,560,360,360,360,960,1760 dw 3360,6560,7680,7680,7680 dw 960,560,3360,6560 ENDP ;----------------------------------------------------------------------------- ; Clear window. ; in: A - color. ;----------------------------------------------------------------------------- Clw PROC A sta _color_CLS_ ldx _is_win_ beq _CLWskip_ LDX 660 ldy 661 stx 32 sty 33 ldy #160 lda _color_CLS_ _loopCLW_: dey sta (32),y cpy #0 bne _loopCLW_ _CLWskip_: rts ifndef _is_win_ _is_win_ db 0 endndef ifndef _color_cls_ _color_cls_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Move the cursor up. ;----------------------------------------------------------------------------- CUp PROC lda 84 beq _cup3_ dec 84 lda 87 bne _cup3_ ; przestaw kursor lda 93 ldy #0 sta (94),y lda 94 sub #40 sta 94 bcs _cup2_ dec 95 _cup2_: lda (94),y sta 93 eor #%10000000 sta (94),y _cup3_: rts ifndef _is_win_ _is_win_ db 0 endndef ifndef _color_cls_ _color_cls_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Move the cursor down. ;----------------------------------------------------------------------------- CDown PROC inc 84 ; przestaw kursor lda 87 bne _cdown1_ lda 93 ldy #0 sta (94),y lda 94 add #40 sta 94 bcc _cdown0_ inc 95 _cdown0_: lda (94),y sta 93 eor #%10000000 sta (94),y _cdown1_: rts ENDP ;----------------------------------------------------------------------------- ; Move the cursor left. ;----------------------------------------------------------------------------- CLeft PROC lda 85 bne _cleft1_ lda 86 beq _cleft3_ dec 86 _cleft1_: dec 85 ; przestaw kursor lda 87 bne _cleft3_ lda 93 ldy #0 sta (94),y lda 94 bne _cleft2_ dec 95 _cleft2_: dec 94 lda (94),y STA 93 eor #%10000000 sta (94),y _cleft3_: rts ENDP ;----------------------------------------------------------------------------- ; Move the cursor to the begin of the line. ;----------------------------------------------------------------------------- CLine PROC ; przestaw kursor lda 87 bne _cleft1_ lda 93 ldy #0 sty 86 sta (94),y lda 94 sub 85 sta 94 lda 95 sbc 86 sta 95 lda 82 sta 85 add 94 sta 94 lda 95 adc #0 sta 95 lda (94),y STA 93 eor #%10000000 sta (94),y rts _cleft1_: lda #0 sta 85 sta 86 rts ENDP ;----------------------------------------------------------------------------- ; Move the cursor right. ;----------------------------------------------------------------------------- CRight PROC inc 85 bne _cright1_ inc 86 _cright1_: lda 87 bne _cright2_ jmp _move_curs_ _cright2_: rts ifndef _move_curs_ _move_curs_: ; przestaw kursor lda 93 ldy #0 sta (94),y inc 94 bne _prin1d_ inc 95 _prin1d_: lda (94),y sta 93 eor #%10000000 sta (94),y rts endndef ENDP ;----------------------------------------------------------------------------- ; Move the cursor home. ;----------------------------------------------------------------------------- CHome PROC lda #0 sta 84 sta 85 sta 86 lda 87 bne _chome3_ ; przestaw kursor lda 93 ldy #0 sta (94),y ldx 88 lda 89 stx 94 sta 95 lda (94),y sta 93 eor #%10000000 sta (94),y _chome3_: rts ENDP ;----------------------------------------------------------------------------- ; Memorize X coordinate. ;----------------------------------------------------------------------------- Memorize&X PROC ldx 85 ldy 86 stx _xpos_ sty _xpos_+1 rts ifndef _xpos_ _xpos_ dw 0 endndef ENDP ;----------------------------------------------------------------------------- ; Memorize Y coordinate. ;----------------------------------------------------------------------------- Memorize&Y PROC ldx 84 stx _ypos_ rts ifndef _ypos_ _ypos_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Remember X coordinate. ;----------------------------------------------------------------------------- Remember&X PROC ldx _xpos_ ldy _xpos_+1 stx 85 sty 86 RTS ifndef _xpos_ _xpos_ dw 0 endndef ENDP ;----------------------------------------------------------------------------- ; Remember Y coordinate. ;----------------------------------------------------------------------------- Remember&Y PROC ldx _ypos_ stx 84 rts ifndef _ypos_ _ypos_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Turn off screen. ;----------------------------------------------------------------------------- Screen&OFF MACRO lda $D400 and #%11011111 sta $D400 ENDM ;----------------------------------------------------------------------------- ; Turn on screen. ;----------------------------------------------------------------------------- Screen&ON MACRO lda $D400 eor #%00100000 sta $D400 ENDM ;----------------------------------------------------------------------------- ; Active VScroll. ; in: A - shift of row. ;----------------------------------------------------------------------------- VScroll PROC A sta 54277 rts ENDP ;----------------------------------------------------------------------------- ; Active HScroll. ; in: A - shift of column. ;----------------------------------------------------------------------------- HScroll PROC A sta 54277 rts ENDP ;----------------------------------------------------------------------------- ; Wait for vertical retrace. ;----------------------------------------------------------------------------- WaitVBL PROC _waitvbl_: lda 54283 cmp #120 ;240/2 bcc _waitvbl_ rts ENDP ;----------------------------------------------------------------------------- ; Draw circle. ; in: ((_cenx_)) - X coordinate. ; (_ceny_) - Y coordinate. ; (_radius_) - radius. ;----------------------------------------------------------------------------- Circle PROC ((_cenx_)),(_ceny_),(_radius_) lda _radius_ ;cy=radius sta _c_y_ sta _cyy_ lda #0 sta _radius_+1 sta _c_x_ sta _cxx_ asl _radius_ ;delta=3-2*radius rol _radius_+1 lda #3 sec sbc _radius_ sta _deltac_ lda #0 sbc _radius_+1 sta _deltac_+1 lda _circlecol_ cmp #255 bne _circleff_ ;narysuj sam okr¥g... lda <_plotmax_ sta _cir001_+1 sta _cir002_+1 sta _cir003_+1 sta _cir004_+1 lda >_plotmax_ sta _cir001_+2 sta _cir002_+2 STA _cir003_+2 sta _cir004_+2 jmp _circlef1_ _circleff_: ;narysuj wypeˆniony okr¥g... lda <_drawtomax_ sta _cir001_+1 sta _cir002_+1 sta _cir003_+1 sta _cir004_+1 lda >_drawtomax_ sta _cir001_+2 sta _cir002_+2 sta _cir003_+2 sta _cir004_+2 _circlef1_: lda _circlecol_ sta 763 ldx _cxx_ cpx _cyy_ bmi _circlef2_ ;cx=0 lda #0 ;delta=delta+4*cx+6 sta _cpom2_ lda _c_x_ asl @ rol _cpom2_ asl @ rol _cpom2_ clc adc #6 _circlef3_: sta _cpom1_ lda #0 adc _cpom2_ sta _cpom2_ lda _deltac_ clc adc _cpom1_ sta _deltac_ lda _deltac_+1 adc _cpom2_ sta _deltac_+1 inc _cxx_ jmp _circlef1_ _circlef4_: lda #255 ;delta=delta+4*(cx-cy)+10 sta _cpom2_ lda _c_x_ sec sbc _c_y_ ASL @ rol _cpom2_ asl @ rol _cpom2_ clc adc #10 dec _cyy_ jmp _circlef3_ _circlef5_: rts _circle_correct_: ldx _cxx_ stx _c_x_ lda 87 cmp #9 bmi _c_cor1_ cmp #14 bpl _c_cor0_ lsr _c_x_ _c_cor0_: lsr _c_x_ _c_cor1_: rts _ycircle_correct_: ldy _cyy_ sty _c_y_ lda 87 cmp #9 bmi _c_cor1y_ cmp #14 bpl _c_cor0y_ lsr _c_y_ _c_cor0y_: lsr _c_y_ _c_cor1y_: rts ;zmienne _circlecol_ db 0 _deltac_=67 ;(2) _radius_=69 ;(2) _cpom1_ db 0 _cpom2_ db 0 _cenx_=71 ;(2) _ceny_=73 _cxx_ DB 0 _c_x_=74 _cyy_ db 0 _c_y_=75 PLOT 0,0 DRAWTO 0,0 ENDP ;----------------------------------------------------------------------------- ; Stop program. ; in: YX - time in 1/50 s. ;----------------------------------------------------------------------------- Pause PROC XY lda #5 ;TIMCNT5 jsr 58460 _paus1_: lda 545 bne _paus1_ _paus2_: lda 544 bne _paus2_ rts ENDP ;----------------------------------------------------------------------------- ; Change the ATASCII code to the INTERNAL code. ;----------------------------------------------------------------------------- ConvertINT PROC ldx #%00000000 cmp #128 bcc _skipATA1_ ldx #%10000000 and #%01111111 ;-128 _skipATA1_: stx _inv_ cmp #32 bcs _skipATA2_ add #64 ora _inv_ rts _skipATA2_: cmp #96 bcs _skipATA3_ sub #32 _skipATA3_: ora _inv_ rts ifndef _inv_ _inv_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Change the INTERNAL code to the ATASCII code. ;----------------------------------------------------------------------------- ConvertASC PROC ldx #%00000000 cmp #128 bcc _asc1_ ldx #%10000000 and #%01111111 ;-128 _asc1_: stx _inv_ cmp #64 bcs _asc2_ add #32 ora _inv_ rts _asc2_: cmp #96 bcs _asc3_ sub #64 _asc3_: ora _inv_ rts ifndef _inv_ _inv_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Print a text with EOL. ; in: YX - text. ;----------------------------------------------------------------------------- PrintE MACRO text Print text CDown CLine ENDM ;----------------------------------------------------------------------------- ; Print a text without EOL. ; in: YX - text. ;----------------------------------------------------------------------------- Print PROC YX lda 87 cmp #3 bpl _prin2_ _prin1_: stx 32 sty 33 ldy #255 sty _county_ _prin1a_: inc _county_ ldy _county_ lda (32),y cmp #155 bne _prin1b_ jsr _move_curs_ jmp _print_b_ _print_q_: lda 87 bne _print_b_ lda 93 ldy #0 sta (94),y jsr _prin1d_ ;tylko dla trybu 0 wida† ;efekt! _print_b_: lda 87 bne _printtt_ lda _is_cursor_ bne _print_a_ CURSOR OFF rts _print_a_: CURSOR ON _printtt_: rts _prin1b_: ConvertINT sta 763 PLOT ((85)),(84) inc 85 jmp _prin1a_ _prin2_: cmp #12 beq _prin1_ cmp #13 beq _prin1_ stx 32 sty 33 ldy #255 sty _county_ _prin3_: inc _county_ ldy _county_ lda (32),y cmp #155 bne _prin5_ rts ;_print_line_: ; LDA #0 ;przejd« do nast©pnej linii! ; sta 85 ; sta 86 ; lda 84 ; clc ; adc #8 ; sta 84 ;_print_gr_: ; rts _prin5_: ; cmp #155 ; beq _print_line_ tax and #%01111111 cmp #32 bpl _prin50_ txa clc adc #64 jmp _prin51_ _prin50_: cmp #96 bpl _prin51_ txa sec sbc #32 _prin51_: ldx #0 stx 35 asl @ rol 35 asl @ rol 35 asl @ rol 35 sta 34 lda 35 clc adc 756 sta 35 ldy #0 sty _countp_ jmp _prin7_ _prin6_: inc 84 lda 85 sec sbc #9 sta 85 lda 86 sbc #0 sta 86 _prin7_: ldy _countp_ lda (34),y sta 36 ldx #9 stx 37 _prin8_: asl 36 bcc _prin9_ PLOT ((_px_)),(_py_) _prin9_: inc 85 bne _prin10_ inc 86 _prin10_: dec 37 bne _prin8_ inc _countp_ lda _countp_ cmp #8 bmi _prin6_ lda 84 sec sbc #7 sta 84 jmp _prin3_ _print_number_: lda #0 sta _pos_ lda #4 sta _print_val_ _loop_prin_: LDA _print_val_ asl @ tay lda _print_tab_,y sta _btb_+2 lda _print_tab_+1,y sta _btb_+3 jsr _div_print_ lda _rsl_ clc adc #'0' ldy _pos_ sta _number_,y inc _pos_ dec _print_val_ bpl _loop_prin_ ldx <_number_ ldy >_number_ stx 32 sty 33 ldy #255 _print_l0_: iny lda (32),y cmp #'0' beq _print_l0_ cmp #0 bne _skip_l0_ dey _skip_l0_: tya sty _len_val_ clc adc 32 tax lda 33 adc #0 tay rts ifndef _move_curs_ _move_curs_: ; przestaw kursor lda 93 LDY #0 sta (94),y inc 94 bne _prin1d_ inc 95 _prin1d_: lda (94),y STA 93 eor #%10000000 sta (94),y rts endndef ifndef _eol_ _eol_ db 0 endndef ifndef _is_cursor_ _is_cursor_ db 1 endndef _len_val_ DB 0 _column_ db 0 _row_ db 0 _countp_ db 0 _county_ db 0 _px_=85 ;(2) _py_=84 _number_ db ' ',0 _pos_ db 0 _print_val_ db 0 _print_tab_ dw 1,10,100,1000,10000 DIV ;wpisz procedur© dzielenia! ifndef _is_graph_ _is_graph_ db 0 endndef ENDP ;----------------------------------------------------------------------------- ; Centre a text on the screen. ; in: YX - text. ;----------------------------------------------------------------------------- Centre MACRO text XPosCentre text PrintE text ENDM XPosCentre PROC YX stx 32 sty 33 ldy #255 _cen_lab1_: iny lda (32),y bne _cen_lab1_ sty _cenpom_ ldy 87 lda _CentreTAB_,y sub _cenpom_ lsr @ cpy #3 bpl _centre1_ _centre0_: sta 85 lda #0 sta 86 rts _centre1_: cpy #12 beq _centre0_ cpy #13 beq _centre0_ clc asl @ ;*8 asl @ asl @ sta 85 ldx #0 bcc _centre2_ inx _centre2_: stx 86 rts _CentreTAB_: DB 40,20,20,40/8,80/8,80/8,160/8,160/8,320/8 DB 80/8,80/8,80/8,40,40,160/8,160/8 _cenpom_ DB 0 ENDP ;----------------------------------------------------------------------------- ; Draw a line. ; in: AX - coordinate X. ; Y - coordinate Y. ;----------------------------------------------------------------------------- DrawTo PROC AX,Y ; ----------------------- ; draw routine 1.0 ; ----------------------- STX _xd1_ STA _xd1_+1 STY _yd1_ _drawtomax_: lda 87 cmp #15 beq _drawto15_ cmp #7 beq _drawto15_ lda #17 STA 928+2 sta 928+8 ldx <_sname_ ldy >_sname_ stx 928+4 STY 928+5 LDX #96 jmp 58454 IfNDef _sname_ _sname_ db c'S:',155 endndef _drawto15_: lda #$00 sta _cx_ sta _cy_ sec lda _xd1_ sbc _xd0_ bcs _d0_ dec _cx_ EOR #$ff adc #$01 _d0_: sta _dx_ sec LDA _yd1_ sbc _yd0_ bcs _d1_ DEC _cy_ eor #$ff adc #$01 _d1_: STA _dy_ cmp _dx_ bcs _zy_ ; ------------ ; Always X !!! ; ------------ _zx_: ldx _dx_ ; always X INX lda _dy_ ; Czy linia pozioma ? beq _vdr00_ txa lsr @ STA _err_ lda _cx_ EOR _cy_ BNE _zxb_ _zxa_: LDA _cy_ beq *+14 jsr _set_pos_ jsr _set_skip3_ jsr _count_addr_ jmp *+12 jsr _set_skip3_ jsr _count_addr_ jsr _set_pos_ SEC ldy #0 _ru0_: JMP $FFFF ;----------------------------------- _vdr00_: ;wykryto poziom¥ lini©! lda 763 ;wstaw kolor and #3 TAY lda _CTab_,y sta _drawcol_ TYA sta _v03_+3 asl @ ASL @ sta _v02_+3 asl @ asl @ sta _v01_+3 asl @ asl @ sta _vdr2_+5 LDA _cx_ beq _ruc_ LDA _xd1_ sta _xd0_ lda _xd1_+1 sta _xd0_+1 lda _yd1_ STA _yd0_ lda _xd0_ and #$03 tay lda _tv0_,y sta _ruv_+1 LDA _tv1_,Y STA _ruv_+2 jsr _count_addr_ sec ldy #0 lda (_ad0_),y _ruv_: jmp $FFFF _ruc_: lda _xd0_ AND #$03 tay LDA _tv0_,Y sta _ruu_+1 lda _tv1_,y sta _ruu_+2 jsr _count_addr_ LDA _xd1_ sta _xd0_ lda _xd1_+1 sta _xd0_+1 lda _yd1_ sta _yd0_ SEC ldy #0 lda (_ad0_),y _ruu_: jmp $FFFF _vdr0_: ;maksymalny speed!!! inc _ad0_ bne _v00_ inc _ad0_+1 _v00_: txa LSR @ lsr @ ;ile bajt¢w ? beq _vdr2_ tay sty _dry_ LDA _drawcol_ jmp *+5 _vdr1_: sta (_ad0_),y dey bne _vdr1_ STA (_ad0_),Y txa and #3 beq _vdr4_ TAX ldy _dry_ _vdr2_: lda (_ad0_),y and #%00111111 ORA #%11000000 dex BEQ _vdr3_ _v01_: and #%11001111 ora #%00110000 dex BEQ _vdr3_ _v02_: and #%11110011 ora #%00001100 dex beq _vdr3_ _v03_: and #%11111100 ora #%00000011 sta (_ad0_),y dex bne _vdr0_ _vdr3_: sta (_ad0_),y _vdr4_: RTS _dry_=58 _drawcol_=59 ifndef _CTab_ _CTab_ db b(0),b(%01010101),b(%10101010),b(%11111111) endndef ;-------------------------------- _set_skip3_: lda _xd0_ and #$03 tay lda _ta0_,y sta _ru0_+1 LDA _ta1_,Y sta _ru0_+2 lda 763 ;wstaw kolor and #3 sta _a03_+5 asl @ asl @ STA _a02_+5 asl @ ASL @ sta _a01_+5 ASL @ asl @ sta _a00_+5 rts _zxb_: LDA _cy_ bne *+14 jsr _set_pos_ jsr _set_skip4_ jsr _count_addr_ jmp *+12 JSR _set_skip4_ jsr _count_addr_ jsr _set_pos_ sec ldy #0 _ru1_: jmp $FFFF _set_skip4_: lda _xd0_ AND #$03 tay LDA _tb0_,Y sta _ru1_+1 lda _tb1_,y sta _ru1_+2 lda 763 ;wstaw kolor AND #3 sta _b03_+5 asl @ asl @ sta _b02_+5 asl @ ASL @ sta _b01_+5 asl @ asl @ sta _b00_+5 rts ; ------------ ; Always Y !!! ; ------------ _zy_: ldx _dy_ inx txa lsr @ STA _err_ lda _cx_ eor _cy_ bne _zyb_ _zya_: LDA _cx_ beq *+14 jsr _set_pos_ jsr _set_skip1_ jsr _count_addr_ jmp *+12 jsr _set_skip1_ jsr _count_addr_ jsr _set_pos_ SEC ldy #0 _ru2_: JMP $FFFF _set_skip1_: lda _xd0_ and #$03 TAY lda _tc0_,y sta _ru2_+1 lda _tc1_,y sta _ru2_+2 lda 763 ;wstaw kolor AND #3 sta _c03_+5 asl @ asl @ sta _c02_+5 asl @ asl @ sta _c01_+5 asl @ ASL @ sta _c00_+5 RTS _zyb_: LDA _cx_ beq *+14 jsr _set_pos_ JSR _set_skip2_ jsr _count_addr_ jmp *+12 jsr _set_skip2_ jsr _count_addr_ jsr _set_pos_ SEC ldy #0 _ru3_: jmp $FFFF _set_skip2_: lda _xd0_ and #$03 tay lda _td0_,y STA _ru3_+1 lda _td1_,y STA _ru3_+2 lda 763 ;wstaw kolor and #3 sta _d03_+5 asl @ ASL @ sta _d02_+5 asl @ asl @ sta _d01_+5 asl @ ASL @ sta _d00_+5 rts ; ---------------------------------- _ta0_ db l(_a00_),l(_a01_),l(_a02_),l(_a03_) _ta1_ db h(_a00_),h(_a01_),h(_a02_),h(_a03_) _tb0_ db l(_b00_),l(_b01_),l(_b02_),l(_b03_) _tb1_ db h(_b00_),h(_b01_),h(_b02_),h(_b03_) _tc0_ db l(_c00_),l(_c01_),l(_c02_),l(_c03_) _tc1_ DB H(_c00_),H(_c01_),H(_c02_),H(_c03_) _td0_ db l(_d00_),l(_d01_),l(_d02_),l(_d03_) _td1_ DB H(_d00_),H(_d01_),H(_d02_),H(_d03_) _tv0_ db l(_v00_),l(_v01_),l(_v02_),l(_v03_) _tv1_ db h(_v00_),h(_v01_),h(_v02_),h(_v03_) ; ---------------------------------- ; Always Y,type A _dq4_: rts sta _err_ _c00_: lda (_ad0_),y and #%00111111 ora #%11000000 STA (_ad0_),Y dex beq _dq4_ php lda _ad0_ clc adc #40 sta _ad0_ bcc *+4 INC _ad0_+1 plp LDA _err_ sbc _dx_ bcs _c00_-2 adc _dy_ sta _err_ _c01_: LDA (_ad0_),Y and #%11001111 ora #%00110000 sta (_ad0_),y dex beq _dq4_ PHP lda _ad0_ clc adc #40 sta _ad0_ bcc *+4 inc _ad0_+1 plp lda _err_ SBC _dx_ bcs _c01_-2 ADC _dy_ sta _err_ _c02_: lda (_ad0_),y and #%11110011 ora #%00001100 STA (_ad0_),Y dex beq _dq4_ PHP lda _ad0_ clc ADC #40 sta _ad0_ bcc *+4 inc _ad0_+1 plp lda _err_ sbc _dx_ bcs _c02_-2 adc _dy_ STA _err_ _c03_: lda (_ad0_),y AND #%11111100 ora #%00000011 sta (_ad0_),y dex beq _dq4_ PHP lda _ad0_ clc adc #40 sta _ad0_ bcc *+4 INC _ad0_+1 plp LDA _err_ sbc _dx_ bcs _c03_-2 adc _dy_ iny jmp _c00_-2 ; --------------- ; Always Y,type B _dq6_: RTS STA _err_ _d00_: LDA (_ad0_),Y AND #%00111111 ORA #%11000000 STA (_ad0_),Y DEX BEQ _dq6_ PHP LDA _ad0_ SEC SBC #40 STA _ad0_ BCS *+4 dec _ad0_+1 plp lda _err_ sbc _dx_ bcs _d00_-2 ADC _dy_ sta _err_ _d01_: LDA (_ad0_),Y and #%11001111 ora #%00110000 sta (_ad0_),y dex BEQ _dq6_ php lda _ad0_ sec sbc #40 sta _ad0_ BCS *+4 dec _ad0_+1 PLP lda _err_ sbc _dx_ bcs _d01_-2 adc _dy_ sta _err_ _d02_: lda (_ad0_),y AND #%11110011 ora #%00001100 STA (_ad0_),Y dex beq _dq6_ php lda _ad0_ SEC sbc #40 sta _ad0_ bcs *+4 dec _ad0_+1 plp LDA _err_ sbc _dx_ BCS _d02_-2 ADC _dy_ sta _err_ _d03_: lda (_ad0_),y and #%11111100 ora #%00000011 sta (_ad0_),y DEX beq _dq6_ PHP lda _ad0_ sec sbc #40 sta _ad0_ BCS *+4 dec _ad0_+1 plp lda _err_ sbc _dx_ bcs _d03_-2 ADC _dy_ INY jmp _d00_-2 ; --------------- ; Always X,type A _dq0_: rts _a00_: lda (_ad0_),y AND #%00111111 ora #%11000000 STA (_ad0_),Y dex beq _dq0_ lda _err_ sbc _dy_ STA _err_ bcs _a01_ adc _dx_ sta _err_ php lda _ad0_ CLC adc #40 STA _ad0_ bcc *+4 inc _ad0_+1 plp _a01_: LDA (_ad0_),Y and #%11001111 ora #%00110000 STA (_ad0_),Y dex BEQ _dq0_ lda _err_ sbc _dy_ sta _err_ bcs _a02_ ADC _dx_ sta _err_ php lda _ad0_ clc adc #40 STA _ad0_ bcc *+4 INC _ad0_+1 plp _a02_: lda (_ad0_),y and #%11110011 ora #%00001100 sta (_ad0_),y dex BEQ _dq0_ lda _err_ SBC _dy_ sta _err_ bcs _a03_ adc _dx_ sta _err_ PHP lda _ad0_ clc adc #40 sta _ad0_ bcc *+4 INC _ad0_+1 plp _a03_: LDA (_ad0_),Y and #%11111100 ora #%00000011 sta (_ad0_),y dex beq _dq0_ lda _err_ SBC _dy_ sta _err_ BCS _a04_ adc _dx_ sta _err_ php lda _ad0_ CLC adc #40 sta _ad0_ bcc *+4 inc _ad0_+1 plp _a04_: INY jmp _a00_ ; ----------------- ; always X,type B _dq2_: rts _b00_: lda (_ad0_),y AND #%00111111 ora #%11000000 STA (_ad0_),Y dex beq _dq2_ lda _err_ sbc _dy_ STA _err_ bcs _b01_ adc _dx_ sta _err_ php lda _ad0_ SEC sbc #40 STA _ad0_ bcs *+4 dec _ad0_+1 plp _b01_: lda (_ad0_),y and #%11001111 ora #%00110000 STA (_ad0_),Y dex BEQ _dq2_ LDA _err_ sbc _dy_ sta _err_ bcs _b02_ ADC _dx_ sta _err_ php lda _ad0_ sec sbc #40 STA _ad0_ bcs *+4 DEC _ad0_+1 plp _b02_: lda (_ad0_),y and #%11110011 ora #%00001100 sta (_ad0_),y dex BEQ _dq2_ lda _err_ SBC _dy_ sta _err_ bcs _b03_ adc _dx_ sta _err_ PHP lda _ad0_ sec sbc #40 sta _ad0_ bcs *+4 DEC _ad0_+1 plp _b03_: LDA (_ad0_),Y and #%11111100 ora #%00000011 sta (_ad0_),y dex beq _dq2_ lda _err_ SBC _dy_ sta _err_ BCS _b04_ adc _dx_ sta _err_ php LDA _ad0_ SEC sbc #40 sta _ad0_ bcs *+4 dec _ad0_+1 plp _b04_: INY jmp _b00_ _set_pos_: ;ustawienie wsp¢ˆrz©dnych dla nast©pnych drawto... lda _xd1_ sta _xd0_ lda _xd1_+1 STA _xd0_+1 lda _yd1_ STA _yd0_ rts ; wylicza dokˆadny adres na podst. x,y ifndef _count_addr_ _count_addr_: ;mno¾enie _yd0_*32+_yd0_*8 lda _yd0_ lsr @ lsr @ lsr @ TAY lsr @ LSR @ sta _ad0_+1 lda _yd0_ asl @ asl @ asl @ sta _ad0_ ASL @ asl @ CLC adc _ad0_ sta _ad0_ tya adc _ad0_+1 STA _ad0_+1 ;dodanie _xd0_/4 LDA _xd0_ lsr @ lsr @ clc ADC _ad0_ sta _ad0_ BCC _counta1_ inc _ad0_+1 _counta1_: lda 88 clc adc _ad0_ sta _ad0_ LDA 89 adc _ad0_+1 STA _ad0_+1 rts endndef ifndef _ad0_ _ad0_=51 ;(2) endndef ifndef _xd0_ _xd0_=91 ;(2) _yd0_=90 endndef IfNDef _xd1_ _xd1_=85 ;(2) _yd1_=84 EndNDef _dx_=53 _dy_=54 _cx_=55 _cy_=56 _err_=57 ENDP ;----------------------------------------------------------------------------- ; Set palette from the GFX picture. ; in: YX - address. ;----------------------------------------------------------------------------- PaletteGFX PROC YX STX 32 STY 33 LDY #8 LDA (32),Y STA 712 LDA 87 LDX #4 CMP #10 ;czy tryb 10 ? beq _palgfx2_ _palgfx1_: INY lda (32),y sta 708-9,y dex bne _palgfx1_ rts _palgfx2_: ldx #9 _palgfx3_: iny lda (32),y STA 704-9,Y DEX BNE _palgfx3_ RTS ENDP ;----------------------------------------------------------------------------- ; Show the GFX picture. ; in: ((85)) - X coordinate. ; A - Y coordinate. ; YX - address. ;----------------------------------------------------------------------------- ShowGFX PROC ((85)),A,YX ;na razie dziaˆa w 100 % z trybami 7,15 ! STX _gfx_ STY _gfx_+1 STA 84 LDY #0 LDA #'G' ;testuj, czy napewno GFX ? CMP (_gfx_),Y BNE _no_gfx_ INY LDA #'F' CMP (_gfx_),Y BNE _no_gfx_ INY LDA #'X' CMP (_gfx_),Y BNE _no_gfx_ PLOT ((85)),(84) ;w 51,52 - address ! LDY #4 LDA (_gfx_),Y LSR @ LSR @ STA _width_gfx_ STA _width_pom_ LDY #6 LDA (_gfx_),Y STA _high_gfx_ LDA 85 AND #3 STA _x_rol_ ;wyznacz maksymalny x w bajtach! LDA 85 LSR @ LSR @ STA _max_x_ LDY 87 LDA _BytesTAB_,Y SUB _max_x_ STA _max_x_ LDX _x_rol_ BEQ _gfx_cont_ DEC _max_x_ _gfx_cont_: ;wyznacz maksymalny y w liniach! ldy 87 lda _LinesTAB_,y sub 84 sta _max_y_ lda #17 add _gfx_ sta _gfx_ lda #0 adc _gfx_+1 sta _gfx_+1 _loop_str_: ldy #255 ldx _x_rol_ beq _loop_gfx_ iny lda (_gfx_),y _loop_gfx1_: lsr @ LSR @ dex bne _loop_gfx1_ sta (_saddr_),y dey _loop_gfx_: iny cpy _max_x_ beq _gfx_skip_ lda (_gfx_),y ldx _x_rol_ beq _gfx_2_ sta _data_gfx_ INY lda (_gfx_),y clc _gfx_1_: lsr _data_gfx_ ror @ LSR _data_gfx_ ror @ DEX bne _gfx_1_ sta (_saddr_),y DEY jmp _gfx_3_ _gfx_2_: sta (_saddr_),y _gfx_3_: dec _width_pom_ bne _loop_gfx_ iny _gfx_skip_: TYA add _width_pom_ adc _gfx_ sta _gfx_ lda #0 adc _gfx_+1 STA _gfx_+1 ldx 87 lda _BytesTAB_,x add _saddr_ STA _saddr_ lda _saddr_+1 adc #0 sta _saddr_+1 lda _width_gfx_ sta _width_pom_ dec _max_y_ beq _gfx_rts_ DEC _high_gfx_ bne _loop_str_ _gfx_rts_: RTS _no_gfx_: Color 1 Position 0,0 PRINTE 'ERROR: THIS IS NOT THE GFX FILE!' JMP * _gfx_=32 ;(2) _width_gfx_=34 ;(2) _width_pom_=36 ;(2) _high_gfx_=38 ;(2) _max_x_=40 ;(2) _max_y_=42 _data_gfx_=43 _x_rol_=44 _saddr_=51 ;(2) _BytesTAB_: ;liczba bajt¢w w linii DB 40,20,20,10,10,20,20,40,40,40,40,40,40 DB 40,20,40 _LinesTAB_: ;liczba linii w trybie 0-15 DB 24,24,12,24,48,48,96,96,192,192,192 DB 192,24,12,192,192 ENDP ;----------------------------------------------------------------------------- ; Draw the rectange. ; in: ((_box_a_)) - X1 coordinate. ; (_box_b_) - Y1 coordinate. ; AX - X2 coordinate. ; Y - Y2 coordinate. ;----------------------------------------------------------------------------- Box PROC ((_box_a_)),(_box_b_),AX,Y STX _box_x_ STA _box_x_+1 STY _box_y_ PLOT ((_box_a_)),(_box_b_) DRAWTO ((_box_x_)),(_box_b_) DRAWTO ((_box_x_)),(_box_y_) DRAWTO ((_box_a_)),(_box_y_) DRAWTO ((_box_a_)),(_box_b_) RTS IfNDef _box_a_ _box_a_ DW 0 _box_b_ DB 0 _box_x_ DW 0 _box_y_ DB 0 EndNDef ENDP ;----------------------------------------------------------------------------- ; Draw the line. ; in: ((_box_a_)) - X1 coordinate. ; (_box_b_) - Y1 coordinate. ; AX - X2 coordinate. ; Y - Y2 coordinate. ;----------------------------------------------------------------------------- Line PROC ((_box_a_)),(_box_b_),AX,Y STX _box_x_ STA _box_x_+1 STY _box_y_ PLOT ((_box_a_)),(_box_b_) DRAWTO ((_box_x_)),(_box_y_) RTS IfNDef _box_a_ _box_a_ DW 0 _box_b_ DB 0 _box_x_ DW 0 _box_y_ DB 0 EndNDef ENDP ;----------------------------------------------------------------------------- ; Draw the full rectangle. ; in: ((_box_a_)) - X1 coordinate. ; (_box_b_) - Y1 coordinate. ; AX - X2 coordinate. ; Y - Y2 coordinate. ;----------------------------------------------------------------------------- Bar PROC ((_box_a_)),(_box_b_),AX,Y STX _box_x_ STA _box_x_+1 STY _box_y_ LDA 87 ; CMP #15 ; beq _bar01_ ; cmp #7 ; beq _bar01_ _loop_bar_: PLOT ((_box_a_)),(_box_b_) DRAWTO ((_box_x_)),(_box_b_) INC _box_b_ LDA _box_b_ CMP _box_y_ BCC _loop_bar_ BEQ _loop_bar_ RTS _bar01_: STX _xd0_ STY _yd0_ LDA _box_x_+1 sta _xd0_+1 jsr _count_addr_ IfNDef _box_a_ _box_a_ DW 0 _box_b_ DB 0 _box_x_ DW 0 _box_y_ DB 0 EndNDef ENDP ;----------------------------------------------------------------------------- ; Close the file. ; in: A - channel. ;----------------------------------------------------------------------------- Close PROC A ASL @ ASL @ ASL @ ASL @ TAX LDA #255 STA 832,X RTS ENDP ;----------------------------------------------------------------------------- ; Dark the screen. ; in: A - time 1/50 s. ;----------------------------------------------------------------------------- Dark PROC A STA 32 LDA #16 STA 33 _dark0_: ldx #9 _dark1_: LDA 703,X AND #%00001111 BEQ _dark2_ DEC 703,X _dark2_: DEX BNE _dark1_ Pause (32) DEC 33 BNE _dark0_ RTS ENDP ;----------------------------------------------------------------------------- ; Light the screen. ; in: A - time 1/50 s. ;----------------------------------------------------------------------------- Light PROC A STA 32 LDA #16 STA 33 _LIGHT0_: LDX #9 _LIGHT1_: LDA 703,X AND #%00001111 CMP #15 BEQ _LIGHT2_ INC 703,X _LIGHT2_: DEX BNE _LIGHT1_ Pause (32) DEC 33 BNE _LIGHT0_ RTS ENDP ;----------------------------------------------------------------------------- ; Define one char. ; in: (_char_) - internal code. ; (_b+0-7) - bytes of char. ;----------------------------------------------------------------------------- SetChar PROC (_char_),(_b),(_b+1),(_b+2),(_b+3),(_b+4),(_b+5),(_b+6),(_b+7) LDA 756 CMP #192 BMI _setchar1_ ROM OFF _setchar1_: LDA _char_ ConvertINT STA _char_ LDX #0 STX _char_+1 ASL _char_ ;*8 ROL _char_+1 ASL _char_ ROL _char_+1 ASL _char_ ROL _char_+1 LDA 756 ADD _char_+1 ;+CHBASE STA _char_+1 CopyMemory _b1_,((_Char_)),8 RTS _char_ DW 0 _b DW 0,0,0,0 ENDP ;----------------------------------------------------------------------------- ; Install polish chars. ;----------------------------------------------------------------------------- InstallPolish PROC IfNDef _rom_ ROM OFF EndNDef LDA #254 STA $D301 LDX #0 _pol1_: TXA ASL @ TAY lda _adresy_,y sta $70 LDA _tabl_,Y sta $74 iny LDA _adresy_,Y STA $71 LDA _tabl_,Y STA $75 LDY #0 _pol2_: LDA ($74),Y STA ($70),Y INY CPY #8 BNE _pol2_ INX CPX #14 BNE _pol1_ RTS ;zmienne _adresy_: DW 57864,57880,57888 DW 57896,57952,57960 DW 57968,57976,58008 DW 58016,58040,58048 DW 58056,58064 _l1_: DB 0,0,60,6,62,102,62,7 _l2_: DB 12,24,60,96,96,96,60,0 _l3_: DB 12,24,60,102,96,96,102,60 _l4_: DB 0,0,60,102,126,96,60,6 _l5_: DB 0,56,28,24,56,24,60,0 _l6_: DB 0,56,30,60,120,24,60,0 _l7_: DB 12,24,124,102,102,102,102,0 _l8_: DB 12,24,60,102,102,102,60,0 _l9_: DB 12,24,62,96,60,6,124,0 _l10_: DB 12,24,60,96,60,6,6,60 _l11_: DB 12,24,126,12,24,48,126,0 _l12_: DB 24,0,126,12,24,48,126,0 _l13_: DB 12,24,126,12,24,48,96,126 _l14_: DB 24,0,126,12,24,48,96,126 _tabl_ DW _l1_,_l2_,_l3_,_l4_,_l5_,_l6_,_l7_,_l8_,_l9_,_l10_,_l11_,_l12_ DW _l13_,_l14_ ENDP