]> git.sur5r.net Git - cc65/commitdiff
more cleanup
authormrdudz <mrdudz@users.noreply.github.com>
Sun, 29 Nov 2015 19:04:10 +0000 (20:04 +0100)
committermrdudz <mrdudz@users.noreply.github.com>
Sun, 29 Nov 2015 19:04:10 +0000 (20:04 +0100)
13 files changed:
asminc/gamate.inc
cfg/gamate.cfg
include/gamate.h
include/time.h
libsrc/gamate/clrscr.s
libsrc/gamate/cputc.s
libsrc/gamate/crt0.s
libsrc/gamate/extzp.inc
libsrc/gamate/extzp.s
libsrc/gamate/irq.s
libsrc/gamate/nmi.s
testcode/lib/gamate/audiotest.s
testcode/lib/gamate/lcdtest.s

index 167c9b1e183031d00f09d8a2a04580ef47f6ac19..4e7fee2b0b965ea57331334eca2873d5f3a5bb6b 100644 (file)
@@ -51,20 +51,14 @@ COLOR_GREY2     = 1
 COLOR_GREY1     = 2
 COLOR_BLACK     = 3
 
-;-------------------------------------------------------------------------------
 ; bios zp usage:
-;
-; 06/07         address of character set bitplane 1
-; 08/09         address of character set bitplane 2
-; 0a            nmi $4800 echo
-; 0b            irq counter
-; 0c            nmi call cart nmi
-; 0e/0f/10/11   big endian irq counter
-; 15/16/17      ?/xpos/ypos
-;
-; e8            nmi reset to $ff
-;
-
 ZP_NMI_4800     = $0a
-ZP_NMI_ENABLE   = $0c
+ZP_IRQ_COUNT    = $0b
+ZP_IRQ_CTRL     = $0c
+
+ZP_IRQ_CNT1     = $0e
+ZP_IRQ_CNT2     = $0f
+ZP_IRQ_CNT3     = $10
+ZP_IRQ_CNT4     = $11
 
+ZP_NMI_FLAG     = $e8
index d7c87b455c8c399e39e2dec9f985d30d1d734500..90ced1ea5d2eb5299966eff2ccf3be48aa498b63 100644 (file)
@@ -8,7 +8,8 @@ SYMBOLS {
 MEMORY {
         # 0000-03ff is RAM
         # FIXME: what zp range can we actually use?
-        ZP: start = $0020, size = $e0;
+        # $0a-$11 is used by IRQ/NMI, $e8 is used by NMI
+        ZP: start = $0012, size = $e8 - $12;
         CPUSTACK: start = $0100, size =$100;
         RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes;
 
index 7d5c02a9a482f9fc031fde22344e2aeb31013e6d..7b1c04a8198cea66a70eadefecb2b2d9b5118ec9 100644 (file)
@@ -41,7 +41,8 @@
 /*
    base clock cpu clock/32 ?
 
-0/1: 1. channel(right): 12 bit frequency: right frequency 0 nothing, 1 high; 3 23khz; 4 17,3; 10 6,9; 15 4.6; $60 720hz; $eff 18,0; $fff 16,9 hz)
+0/1: 1. channel(right): 12 bit frequency: right frequency 0 nothing, 1 high;
+  3 23khz; 4 17,3; 10 6,9; 15 4.6; $60 720hz; $eff 18,0; $fff 16,9 hz)
  (delay clock/32)
 2/3: 2. channel(left): 12 bit frequency
 4/5: 3. channel(both): 12 bit frequency
 #define LCD_READ        0x5006  /* read from RAM (no auto inc?) */
 #define LCD_DATA        0x5007  /* write to RAM */
 
+/* BIOS zeropage usage */
+
+/* locations 0x0a-0x0c, 0x0e-0x11 and 0xe8 are in use by the BIOS IRQ/NMI handlers */
+#define ZP_NMI_4800     0x0a    /* content of I/O reg 4800 gets copied here each NMI */
+
+#define ZP_IRQ_COUNT    0x0b    /* increments once per IRQ, used elsewhere in the
+                                   BIOS for synchronisation purposes */
+#define ZP_IRQ_CTRL     0x0c    /* if 0 then cartridge irq stubs will not get called */
+
+/* each of the following 4 increments by 1 per IRQ - it is _not_ a 32bit
+   counter (see code at $ffa6 in BIOS)
+   these are not used elsewhere in the bios and can be (re)setted as needed by
+   the user.
+*/
+#define ZP_IRQ_CNT1     0x0e
+#define ZP_IRQ_CNT2     0x0f
+#define ZP_IRQ_CNT3     0x10
+#define ZP_IRQ_CNT4     0x11
+
+#define ZP_NMI_FLAG     0xe8    /* set to 0xff each NMI */
 
 /* constants for the conio implementation */
 #define COLOR_BLACK     0x03
index 33bcbb569bf93cabc25eaf905b80550fdae5fdfd..22e24a56e0ac8d5d44be23070c893d4da3387aeb 100644 (file)
@@ -103,8 +103,8 @@ unsigned _clocks_per_sec (void);
 #  define CLK_TCK               60      /* POSIX */
 #  define CLOCKS_PER_SEC        60      /* ANSI */
 #elif  defined(__GAMATE__)
-#  define CLK_TCK               60      /* POSIX */     /* FIXME */
-#  define CLOCKS_PER_SEC        60      /* ANSI */      /* FIXME */
+#  define CLK_TCK               135     /* POSIX */     /* FIXME */
+#  define CLOCKS_PER_SEC        135     /* ANSI */      /* FIXME */
 #elif  defined(__GEOS__)
 #  define CLK_TCK               1       /* POSIX */
 #  define CLOCKS_PER_SEC        1       /* ANSI */
index c96fc4eda53214d0a2bba77ba683370691ebee70..31a7a1874f7c9431a7a802d6f01f9cff49af17ce 100644 (file)
@@ -6,10 +6,10 @@
         .export _clrscr
 _clrscr:
         ldy     #$0
+        tya
 rowloop:
         sty     LCD_X
 
-        lda     #0
         sta     LCD_Y
 
         ldx     #$0
index 0ebd659b2586d01f26af69cc50dff2327e8ee8a3..7c95ba8fcaa4fcb128d64b73ac3a997d5a61e7e8 100644 (file)
@@ -65,16 +65,6 @@ plot:   ldy     CURS_X
 ; position in Y
 
 putchar:
-
-; FIXME
-;        ora     RVS             ; Set revers bit
-
-;        sty     temp_y
-;        stx     temp_x
-;        sta     temp_a
-
-;        lda     temp_a
-
         sta     ptr3
 
         txa
@@ -139,8 +129,6 @@ putchar:
         bne     @copylp2
 
 @skip_plane2:
-
-
         pla
         tax
         ldy     CURS_X
index 5df5ad38cd6df7c6ad0ade8694d6d93bc3a35509..ead45b7ea1b90bff858e8384fe87db6978e4867d 100644 (file)
@@ -17,8 +17,12 @@ Start:
         sei
         cld
 
+        ldx     #0
+        stx     ZP_IRQ_CTRL     ; disable calling cartridge IRQ/NMI handler
+
         ; Setup stack and memory mapping
-        ldx     #$FF            ; Stack top ($01FF)
+        ;ldx     #$FF            ; Stack top ($01FF)
+        dex
         txs
 
         ; Clear the BSS data
@@ -36,6 +40,8 @@ Start:
         ; Call module constructors
         jsr     initlib
 
+        lda     #1
+        sta     ZP_IRQ_CTRL     ; enable calling cartridge IRQ/NMI handler
         cli     ; allow IRQ only after constructors have run
 
         ; Pass an empty command line
index 3e24d6e4512bf1be279735169933b4fa75a29c35..b6f08bcadc93849f05c830601827313206627c2b 100644 (file)
@@ -1,7 +1,7 @@
 ;
 ; extzp.inc for the Gamate
 ;
-; Groepaz/Hitmen, 2015-11-19
+; Groepaz/Hitmen, 2015-11-27
 ;
 ; Assembler include file that imports the runtime zero page locations used
 ; by the Gamate runtime, ready for usage in asm code.
index d3189dcddb8980225c5eaa88823b4f168ab9b594..41f559233a6136003f92544305095e7ad4615c37 100644 (file)
@@ -1,5 +1,5 @@
 ;
-; Groepaz/Hitmen, 2015-11-19
+; Groepaz/Hitmen, 2015-11-27
 ;
 ; zeropage locations for exclusive use by the library
 ;
index 4adbcb4055ef80565fbb3c4ea6b406446ad58eb3..862307f5897178c3aff035eae5306bd467e81345 100644 (file)
@@ -30,9 +30,10 @@ doneirq:
 ; -> guess 16384 clock cycles = 135,28hz (might be audio signal 1/512?)
 
 IRQStub:
-        pha
-        tya
-        pha
+        ; A and Y are saved by the BIOS
+        ;pha
+        ;tya
+        ;pha
 
         ldy     #<(__INTERRUPTOR_COUNT__ * 2)
         beq     @L1
@@ -45,7 +46,7 @@ IRQStub:
         pla
         tax
 
-@L1:    pla
-        tay
-        pla
+@L1:    ;pla
+        ;tay
+        ;pla
         rts
index 91843134020a1b9b974809125cf876bd4793615c..61db62416743e2c5811b34208990468a7359eb7b 100644 (file)
@@ -3,5 +3,19 @@
 ;
         .export NMIStub
 
+        .segment        "INIT"
+
 NMIStub:
-        rts
\ No newline at end of file
+        ; A is saved by the BIOS
+        ;pha
+        ;txa
+        ;pha
+        ;tya
+        ;pha
+
+        ;pla
+        ;tay
+        ;pla
+        ;tax
+        ;pla
+        rts
index 1b5d22767e26d3a7718fb3a54d47f1f6ad52ca9a..6eab34b22cffe69a2201c43681fa00a075bb9945 100644 (file)
@@ -1,38 +1,40 @@
-
+;
 ; original audiotest.s by PeT (mess@utanet.at)
+;
+; cl65 -t gamate -o audiotest.bin audiotest.s
+;
 
         .include "gamate.inc"
 
         .zeropage
-addr:   .word 0
-psa:   .word 0
-
-.word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 ; get out of sensitiv area
-
-readaddr: .word 0
-editbuffer1: .byte 0,0,0,0, 0,0,0,0 ;0,1,2,3,4,5,6,7
-writeaddr: .word 0
-editbuffer2: .byte 0,0,0,0, 0,0,0,0 ;8,9,$a,$b,$c,$d,$e,$f
-cursor: .byte 0
-controlslast: .byte 0
-controlsedge: .byte 0
-
-.data
-temp_x:        .byte 0
-temp_y:        .byte   0
-temp_a:        .byte 0
-irq_count:     .byte 0
-nmi_count:     .byte 0
-psx:   .byte 0
-psy:   .byte 0
-xpos: .byte 0
-ypos:  .byte 0
-
-        .code
+addr:           .word 0
+psa:            .word 0
+readaddr:       .word 0
+editbuffer1:    .byte 0,0,0,0, 0,0,0,0
+writeaddr:      .word 0
+editbuffer2:    .byte 0,0,0,0, 0,0,0,0
+cursor:         .byte 0
+controlslast:   .byte 0
+controlsedge:   .byte 0
+
+        .bss
+temp_x:         .byte 0
+temp_y:         .byte 0
+temp_a:         .byte 0
+irq_count:      .byte 0
+nmi_count:      .byte 0
+psx:            .byte 0
+psy:            .byte 0
+xpos:           .byte 0
+ypos:           .byte 0
+
+        .rodata
 
 chars:          .incbin "cga2.chr"
 hex2asc:        .byte "0123456789abcdef"
 
+        .code
+
 ;-------------------------------------------------------------------------------
         .export IRQStub, NMIStub
 
@@ -41,7 +43,7 @@ hex2asc:        .byte "0123456789abcdef"
         rts
 .endproc
 
-.proc  IRQStub
+.proc   IRQStub
         inc irq_count
         rts
 .endproc
@@ -50,141 +52,144 @@ hex2asc:        .byte "0123456789abcdef"
         .export Start
 
 .proc   Start
-        lda #>AUDIO_BASE
-        sta writeaddr+1
-        sta readaddr+1
-        lda #<AUDIO_BASE
-        sta writeaddr
-        sta readaddr
-
-        lda #$10
-        sta editbuffer1+6
-        lda #$e
-        sta editbuffer2+5
-        lda #$ff
-        sta editbuffer2+3
-        lda #$ff
-        sta editbuffer2+4
-        lda #$0f
-        sta editbuffer2
-        lda #$0f
-        sta editbuffer2+1
-        lda #$0e
-        sta editbuffer2+2
-        lda    #$38
-        sta editbuffer1+7
-
-        lda #0
-        sta    LCD_XPOS
-        sta LCD_YPOS
-        sta irq_count
-        sta cursor
-        lda #1
-        sta nmi_count
+        sei
+        lda     #0
+        sta     ZP_IRQ_CTRL
+
+        lda     #>AUDIO_BASE
+        sta     writeaddr+1
+        sta     readaddr+1
+        lda     #<AUDIO_BASE
+        sta     writeaddr
+        sta     readaddr
+
+        lda     #$10
+        sta     editbuffer1+6
+        lda     #$e
+        sta     editbuffer2+5
+        lda     #$ff
+        sta     editbuffer2+3
+        lda     #$ff
+        sta     editbuffer2+4
+        lda     #$0f
+        sta     editbuffer2
+        lda     #$0f
+        sta     editbuffer2+1
+        lda     #$0e
+        sta     editbuffer2+2
+        lda     #$38
+        sta     editbuffer1+7
+
+        lda     #0
+        sta     LCD_XPOS
+        sta     LCD_YPOS
+        sta     irq_count
+        sta     cursor
+        lda     #1
+        sta     nmi_count
         cli
-        lda    #LCD_MODE_INC_Y
-        sta    LCD_MODE
+        lda     #LCD_MODE_INC_Y
+        sta     LCD_MODE
 
-        jsr printy
+        jsr     printy
 
-        lda #1
-        sta ZP_NMI_ENABLE
+        lda     #1
+        sta     ZP_IRQ_CTRL
 
-loop:  
-        lda irq_count
+loop:
+        lda     irq_count
 loop1:
-        cmp irq_count
-        beq    loop1
-        lda irq_count
-        and #7
-        bne loop1
-
-        lda    #LCD_MODE_INC_Y
-        sta    LCD_MODE
-
-        ldx #3
-        ldy #32
-        lda irq_count
-        jsr printhex
-
-
-        lda cursor
-        ldy    #0
-        cmp #20
-        bcc firstline
+        cmp     irq_count
+        beq     loop1
+        lda     irq_count
+        and     #7
+        bne     loop1
+
+        lda     #LCD_MODE_INC_Y
+        sta     LCD_MODE
+
+        ldx     #3
+        ldy     #32
+        lda     irq_count
+        jsr     printhex
+
+        lda     cursor
+        ldy     #0
+        cmp     #20
+        bcc     firstline
         sec
-        sbc    #20
-        ldy #24
+        sbc     #20
+        ldy     #24
 firstline:
-        sta LCD_X
-        sty LCD_Y
-        lda #' '
-        jsr printsign
+        sta     LCD_X
+        sty     LCD_Y
+        lda     #' '
+        jsr     printsign
 norclearcursor:
 
-        jsr inputs
+        jsr     inputs
 
-        lda irq_count
-        and #8
-        bne nocursor
-        lda cursor
-        ldy    #0
-        cmp #20
-        bcc firstline2
+        lda     irq_count
+        and     #8
+        bne     nocursor
+        lda     cursor
+        ldy     #0
+        cmp     #20
+        bcc     firstline2
         sec
-        sbc    #20
-        ldy #24
+        sbc     #20
+        ldy     #24
 firstline2:
-        sta LCD_X
-        sty LCD_Y
-        lda #'x'
-        jsr printsign
+        sta     LCD_X
+        sty     LCD_Y
+        lda     #'x'
+        jsr     printsign
 nocursor:
 
-        lda    #LCD_MODE_INC_Y
-        sta    LCD_MODE
-        jsr printy
-        jmp loop
+        lda     #LCD_MODE_INC_Y
+        sta     LCD_MODE
+        jsr     printy
+        jmp     loop
 .endproc
 
 .proc printy
 
-        ldy #0
+        ldy     #0
 loop1: 
         tya
         pha
         asl
         tax
-        lda readaddr,y
-        ldy #8
-        jsr printhex
+        lda     readaddr,y
+        ldy     #8
+        jsr     printhex
         pla
         tay
         iny
-        cpy #10
-        bne loop1
+        cpy     #10
+        bne     loop1
 
 loop2:
         tya
         pha
         tya
         sec
-        sbc #10
+        sbc     #10
         asl
         tax
-        lda readaddr,y
-        ldy #16
-        jsr printhex
+        lda     readaddr,y
+        ldy     #16
+        jsr     printhex
         pla
         tay
         iny
-        cpy #20
-        bne loop2
+        cpy     #20
+        bne     loop2
 
-        ldx #0
-        ldy #32
-        lda nmi_count
-        jsr printhex
+        ldx     #0
+        ldy     #32
+        lda     nmi_count
+        jsr     printhex
 
         rts
 .endproc
@@ -192,187 +197,199 @@ loop2:
 ;-------------------------------------------------------------------------------
 
 .proc inputs
-        lda controlslast
-        eor JOY_DATA
-        and controlslast
-        eor #$ff
-        sta controlsedge
-        and #JOY_DATA_UP
-        bne notup
-
-        lda cursor
+        lda     controlslast
+        eor     JOY_DATA
+        and     controlslast
+        eor     #$ff
+        sta     controlsedge
+        and     #JOY_DATA_UP
+        bne     notup
+
+        lda     cursor
         lsr
         tay
-        bcs uplow
-        lda readaddr,y
+        bcs     uplow
+        lda     readaddr,y
         clc
-        adc #$10
-        sta readaddr,y
-        jmp notup
-uplow:lda readaddr,y
+        adc     #$10
+        sta     readaddr,y
+        jmp     notup
+uplow:
+        lda     readaddr,y
         clc
-        adc #1
-        sta readaddr,y
-notup:lda controlsedge
-        and #JOY_DATA_DOWN
-        bne notdown
-        lda cursor
+        adc     #1
+        sta     readaddr,y
+notup:
+        lda     controlsedge
+        and     #JOY_DATA_DOWN
+        bne     notdown
+        lda     cursor
         lsr
         tay
-        bcs downlow
-        lda readaddr,y
+        bcs     downlow
+        lda     readaddr,y
         sec
-        sbc #$10
-        sta readaddr,y
-        jmp notdown
+        sbc     #$10
+        sta     readaddr,y
+        jmp     notdown
 downlow:
-        lda readaddr,y
+        lda     readaddr,y
         sec
-        sbc #1
-        sta readaddr,y
-notdown:lda controlsedge
-        and #JOY_DATA_LEFT
-        bne notleft
-        lda cursor
-        beq notleft
-        dec cursor
-notleft:lda controlsedge
-        and #JOY_DATA_RIGHT
-        bne notright
-        lda cursor
-        cmp #40
-        beq notright
-        inc cursor
-notright:lda controlsedge
-        and #JOY_DATA_START
-        bne notstart
-        lda #0
-        sta AUDIO_BASE
-        sta AUDIO_BASE+1
-        sta AUDIO_BASE+2
-        sta AUDIO_BASE+3
-        sta AUDIO_BASE+4
-        sta AUDIO_BASE+5
-        sta AUDIO_BASE+6
-        sta AUDIO_BASE+8
-        sta AUDIO_BASE+9
-        sta AUDIO_BASE+10
-        sta AUDIO_BASE+11
-        sta AUDIO_BASE+12
-        sta AUDIO_BASE+13
-        sta AUDIO_BASE+7
-notstart:lda controlsedge
-        and #JOY_DATA_SELECT
-        bne notselect
-        lda editbuffer1
-        sta AUDIO_BASE
-        lda editbuffer1+1
-        sta AUDIO_BASE+1
-        lda editbuffer1+2
-        sta AUDIO_BASE+2
-        lda editbuffer1+3
-        sta AUDIO_BASE+3
-        lda editbuffer1+4
-        sta AUDIO_BASE+4
-        lda editbuffer1+5
-        sta AUDIO_BASE+5
-        lda editbuffer1+6
-        sta AUDIO_BASE+6
-        lda editbuffer2
-        sta AUDIO_BASE+8
-        lda editbuffer2+1
-        sta AUDIO_BASE+9
-        lda editbuffer2+2
-        sta AUDIO_BASE+10
-        lda editbuffer2+3
-        sta AUDIO_BASE+11
-        lda editbuffer2+4
-        sta AUDIO_BASE+12
-        lda editbuffer2+5
-        sta AUDIO_BASE+13
-        lda editbuffer1+7
-        sta AUDIO_BASE+7
-notselect:lda controlsedge
-        and #JOY_DATA_FIRE_A
-        bne notbuttona
-        ldy #0
-        ldy #0
-writea:lda editbuffer1,y
-        sta (writeaddr),y
+        sbc     #1
+        sta     readaddr,y
+notdown:
+        lda     controlsedge
+        and     #JOY_DATA_LEFT
+        bne     notleft
+        lda     cursor
+        beq     notleft
+        dec     cursor
+notleft:
+        lda     controlsedge
+        and     #JOY_DATA_RIGHT
+        bne     notright
+        lda     cursor
+        cmp     #40
+        beq     notright
+        inc     cursor
+notright:
+        lda     controlsedge
+        and     #JOY_DATA_START
+        bne     notstart
+        lda     #0
+        sta     AUDIO_BASE
+        sta     AUDIO_BASE+1
+        sta     AUDIO_BASE+2
+        sta     AUDIO_BASE+3
+        sta     AUDIO_BASE+4
+        sta     AUDIO_BASE+5
+        sta     AUDIO_BASE+6
+        sta     AUDIO_BASE+8
+        sta     AUDIO_BASE+9
+        sta     AUDIO_BASE+10
+        sta     AUDIO_BASE+11
+        sta     AUDIO_BASE+12
+        sta     AUDIO_BASE+13
+        sta     AUDIO_BASE+7
+notstart:
+        lda     controlsedge
+        and     #JOY_DATA_SELECT
+        bne     notselect
+        lda     editbuffer1
+        sta     AUDIO_BASE
+        lda     editbuffer1+1
+        sta     AUDIO_BASE+1
+        lda     editbuffer1+2
+        sta     AUDIO_BASE+2
+        lda     editbuffer1+3
+        sta     AUDIO_BASE+3
+        lda     editbuffer1+4
+        sta     AUDIO_BASE+4
+        lda     editbuffer1+5
+        sta     AUDIO_BASE+5
+        lda     editbuffer1+6
+        sta     AUDIO_BASE+6
+        lda     editbuffer2
+        sta     AUDIO_BASE+8
+        lda     editbuffer2+1
+        sta     AUDIO_BASE+9
+        lda     editbuffer2+2
+        sta     AUDIO_BASE+10
+        lda     editbuffer2+3
+        sta     AUDIO_BASE+11
+        lda     editbuffer2+4
+        sta     AUDIO_BASE+12
+        lda     editbuffer2+5
+        sta     AUDIO_BASE+13
+        lda     editbuffer1+7
+        sta     AUDIO_BASE+7
+notselect:
+        lda     controlsedge
+        and     #JOY_DATA_FIRE_A
+        bne     notbuttona
+        ldy     #0
+        ldy     #0
+writea:
+        lda     editbuffer1,y
+        sta     (writeaddr),y
         iny
-        cpy    #8
-        bne writea
-writeb:lda editbuffer2-8,y
-        sta (writeaddr),y
+        cpy     #8
+        bne     writea
+writeb:
+        lda     editbuffer2-8,y
+        sta     (writeaddr),y
         iny
-        cpy    #16
-        bne writeb
-notbuttona:lda controlsedge
-        and #JOY_DATA_FIRE_B
-        bne notbuttonb
-        ldy #0
-reada:lda (readaddr),y
-        sta editbuffer1,y
+        cpy     #16
+        bne     writeb
+notbuttona:
+        lda     controlsedge
+        and     #JOY_DATA_FIRE_B
+        bne     notbuttonb
+        ldy     #0
+reada:
+        lda     (readaddr),y
+        sta     editbuffer1,y
         iny
-        cpy    #8
-        bne reada
-readb:lda (readaddr),y
-        sta editbuffer2-8,y
+        cpy     #8
+        bne     reada
+
+readb:  lda     (readaddr),y
+        sta     editbuffer2-8,y
         iny
-        cpy    #16
+        cpy     #16
         bne readb
 notbuttonb:
-        lda JOY_DATA
-        sta    controlslast
+        lda     JOY_DATA
+        sta     controlslast
         rts
 .endproc
 
 ;-------------------------------------------------------------------------------
 
 .proc printstring
-        sta    psa
-        stx psa+1
-        ldx #0
-        stx    psx
-        sty psy
+        sta     psa
+        stx     psa+1
+        ldx     #0
+        stx     psx
+        sty     psy
 printstring2:
-        ldy    #0
-        lda    (psa),y
-        beq printstring1
-        ldx psx
-        stx    LCD_X
-        ldy psy
-        sty    LCD_Y
-        jsr printsign
-        inc psx
-        lda psa
+        ldy     #0
+        lda     (psa),y
+        beq     printstring1
+        ldx     psx
+        stx     LCD_X
+        ldy     psy
+        sty     LCD_Y
+        jsr     printsign
+        inc     psx
+        lda     psa
         clc
-        adc    #1
-        sta psa
-        lda psa+1
-        adc    #0
-        sta psa+1
-        jmp printstring2
+        adc     #1
+        sta     psa
+        lda     psa+1
+        adc     #0
+        sta     psa+1
+        jmp     printstring2
 printstring1:
         rts
 .endproc
 
 .proc printstringy
-        sta    psa
-        stx psa+1
+        sta     psa
+        stx     psa+1
 printstring2:
-        ldy    #0
-        lda    (psa),y
-        beq printstring1
-        jsr printsign
-        lda psa
+        ldy     #0
+        lda     (psa),y
+        beq     printstring1
+        jsr     printsign
+        lda     psa
         clc
-        adc    #1
-        sta psa
-        lda psa+1
-        adc    #0
-        sta psa+1
-        jmp printstring2
+        adc     #1
+        sta     psa
+        lda     psa+1
+        adc     #0
+        sta     psa+1
+        jmp     printstring2
 printstring1:
         rts
 .endproc
@@ -384,57 +401,56 @@ printstring1:
         lsr
         lsr
         lsr
-        and #$0f
-        stx    temp_x
+        and     #$0f
+        stx     temp_x
         tax
-        lda    hex2asc,x
-        ldx    temp_x
-        stx    LCD_X
-        sty    LCD_Y
-        jsr    printsign
+        lda     hex2asc,x
+        ldx     temp_x
+        stx     LCD_X
+        sty     LCD_Y
+        jsr     printsign
         pla
-        and    #$0f
+        and     #$0f
         inx
-        stx    temp_x
+        stx     temp_x
         tax
-        lda    hex2asc,x
-        ldx    temp_x
-        stx    LCD_X
-        sty    LCD_Y
-        jmp printsign
+        lda     hex2asc,x
+        ldx     temp_x
+        stx     LCD_X
+        sty     LCD_Y
+        jmp     printsign
 .endproc
 
 .proc printsign
-        sty    temp_y
-        stx    temp_x
-        sta    temp_a
-        lda temp_a
-        sta    addr
-        lda #0
-        sta addr+1
-        asl    addr
-        rol    addr+1
-        asl    addr
-        rol addr+1
-        asl addr
-        rol addr+1
-        lda addr
+        sty     temp_y
+        stx     temp_x
+        sta     temp_a
+        lda     temp_a
+        sta     addr
+        lda     #0
+        sta     addr+1
+        asl     addr
+        rol     addr+1
+        asl     addr
+        rol     addr+1
+        asl     addr
+        rol     addr+1
+        lda     addr
         clc
-        adc    #<chars
-        sta    addr
-        lda    addr+1
-        adc    #>chars
-        sta addr+1
-        ldx    #8
-        ldy #0
+        adc     #<chars
+        sta     addr
+        lda     addr+1
+        adc     #>chars
+        sta     addr+1
+        ldx     #8
+        ldy     #0
 printsign1:
-        lda    (addr),y
-        sta    LCD_DATA
+        lda     (addr),y
+        sta     LCD_DATA
         iny
         dex
-        bne printsign1
-        ldx    temp_x
-        ldy    temp_y
+        bne     printsign1
+        ldx     temp_x
+        ldy     temp_y
         rts
 .endproc
-
index 3ac8f968bb48f51531b66f1e31d123287339848f..3a8d72226eddaa0b530c1c32f3a68ace17e0dd83 100644 (file)
@@ -1,35 +1,39 @@
-
+;
 ; original lcdtest.s by PeT (mess@utanet.at)
+;
+; cl65 -t gamate -o lcdtest.bin lcdtest.s
+;
 
         .include "gamate.inc"
 
         .zeropage
-addr:   .word 0
-psa:   .word 0
-
-        .data
-temp_x:        .byte 0
-temp_y:        .byte   0
-temp_a:        .byte 0
-irq_count:     .byte 0
-nmi_count:     .byte 0
-psx:   .byte 0
-psy:   .byte 0
-count: .word 0
-counted: .word 0
-xpos: .byte 0
-ypos:  .byte 0
-
-.code
-
-chars:
-        .incbin "cga2.chr"
+addr:           .word 0
+psa:            .word 0
+
+        .bss
+temp_x:         .byte 0
+temp_y:         .byte 0
+temp_a:                .byte 0
+irq_count:      .byte 0
+nmi_count:      .byte 0
+psx:            .byte 0
+psy:            .byte 0
+count:          .word 0
+counted:        .word 0
+xpos:           .byte 0
+ypos:           .byte 0
+
+        .rodata
+
+chars:          .incbin "cga2.chr"
 
 hex2asc:        .byte "0123456789abcdef"
 format:         .byte "IrqNmiCountXposYpos", 0
 xdesc:          .byte "0123456789abcdefghijklmnopqrstuv", 0
 ydesc:          .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
 
+        .code
+
 ;-------------------------------------------------------------------------------
         .export IRQStub, NMIStub
 
@@ -57,278 +61,295 @@ ydesc:          .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
         .export Start
 
 .proc   Start
+        sei
+        lda     #0
+        sta     ZP_IRQ_CTRL
 
         lda #0
-        sta    LCD_XPOS
-        sta LCD_YPOS
+        sta     LCD_XPOS
+        sta     LCD_YPOS
         cli
-        lda    #LCD_MODE_INC_Y
-        sta    LCD_MODE
+        lda     #LCD_MODE_INC_Y
+        sta     LCD_MODE
 
-        lda #0
-        sta LCD_X
-        lda #<xdesc
-        ldx    #>xdesc
-        ldy #0
-        jsr printstring
-
-        lda #LCD_XPOS_PLANE2
-        sta LCD_X
-        lda #<xdesc
-        ldx    #>xdesc
-        ldy #128
-        jsr printstring
+        lda     #0
+        sta     LCD_X
+        lda     #<xdesc
+        ldx     #>xdesc
+        ldy     #0
+        jsr     printstring
 
-        lda #0
-        sta LCD_X
-        lda #<ydesc
-        ldx    #>ydesc
-        ldy #0
-        sty    LCD_Y
-        jsr printstringy
-
-;                      lda #$90;(LCD_XPOS_PLANE2|(128/8))
-        lda #(LCD_XPOS_PLANE2|(128/8))
-        sta LCD_X
-        lda #<ydesc
-        ldx    #>ydesc
-        ldy #0
-        sty    LCD_Y
-        jsr printstringy
-
-        lda #<format
-        ldx    #>format
-        ldy #8
-        jsr printstring
+        lda     #LCD_XPOS_PLANE2
+        sta     LCD_X
+        lda     #<xdesc
+        ldx     #>xdesc
+        ldy     #128
+        jsr     printstring
 
-        lda #0
-        sta LCD_MODE
-        lda    #24/8
-        sta LCD_X
-        lda #24
-        sta LCD_Y
-        lda #'X'
-        jsr printsign
-        lda #$80
-        sta LCD_MODE
-        lda #32/8
-        sta LCD_X
-        lda #32
-        sta LCD_Y
-        lda #'Y'
-        jsr printsign
-        lda #$c0
-        sta LCD_MODE
-        lda #40/8
-        sta LCD_X
-        lda    #40
-        sta LCD_Y
-        lda #'Z'
-        jsr printsign
+        lda     #0
+        sta     LCD_X
+        lda     #<ydesc
+        ldx     #>ydesc
+        ldy     #0
+        sty     LCD_Y
+        jsr     printstringy
 
-        lda #0
-        sta LCD_MODE
-        lda    #LCD_XPOS_PLANE2|(48/8)
-        sta LCD_X
-        lda #48
-        sta LCD_Y
-        lda #'x'
-        jsr printsign
-        lda #$80
-        sta LCD_MODE
-        lda    #(LCD_XPOS_PLANE2|(56/8))
-        sta LCD_X
-        lda #56
-        sta LCD_Y
-        lda #'y'
-        jsr printsign
-        lda #$c0
-        sta LCD_MODE
-        lda    #(LCD_XPOS_PLANE2|(64/8))
-        sta LCD_X
-        lda    #64
-        sta LCD_Y
-        lda #'z'
-        jsr printsign
-
-        lda #LCD_MODE_INC_Y|1
-        sta LCD_MODE
-        lda    #16/8
-        sta LCD_X
-        lda #72
-        sta LCD_Y
-        lda #'V'
-        jsr printsign
-        lda #LCD_MODE_INC_Y|2
-        sta LCD_MODE
-        lda    #24/8
-        sta LCD_X
-        lda #72
-        sta LCD_Y
-        lda #'V'
-        jsr printsign
-        lda #LCD_MODE_INC_Y|4
-        sta LCD_MODE
-        lda    #32/8
-        sta LCD_X
-        lda #72
-        sta LCD_Y
-        lda #'V'
-        jsr printsign
-        lda #LCD_MODE_INC_Y|8
-        sta LCD_MODE
-        lda    #40/8
-        sta LCD_X
-        lda #72
-        sta LCD_Y
-        lda #'V'
-        jsr printsign
-
-
-        lda #1
-        sta ZP_NMI_ENABLE
-
-loop:  lda count
+        lda     #(LCD_XPOS_PLANE2|(128/8))          ; ???
+        sta     LCD_X
+        lda     #<ydesc
+        ldx     #>ydesc
+        ldy     #0
+        sty     LCD_Y
+        jsr     printstringy
+
+        lda     #<format
+        ldx     #>format
+        ldy     #8
+        jsr     printstring
+
+        lda     #0
+        sta     LCD_MODE
+        lda     #24/8
+        sta     LCD_X
+        lda     #24
+        sta     LCD_Y
+        lda     #'X'
+        jsr     printsign
+
+        lda     #$80
+        sta     LCD_MODE
+        lda     #32/8
+        sta     LCD_X
+        lda     #32
+        sta     LCD_Y
+        lda     #'Y'
+        jsr     printsign
+
+        lda     #$c0
+        sta     LCD_MODE
+        lda     #40/8
+        sta     LCD_X
+        lda     #40
+        sta     LCD_Y
+        lda     #'Z'
+        jsr     printsign
+
+        lda     #0
+        sta     LCD_MODE
+        lda     #LCD_XPOS_PLANE2|(48/8)
+        sta     LCD_X
+        lda     #48
+        sta     LCD_Y
+        lda     #'x'
+        jsr     printsign
+
+        lda     #$80
+        sta     LCD_MODE
+        lda     #(LCD_XPOS_PLANE2|(56/8))
+        sta     LCD_X
+        lda     #56
+        sta     LCD_Y
+        lda     #'y'
+        jsr     printsign
+
+        lda     #$c0
+        sta     LCD_MODE
+        lda     #(LCD_XPOS_PLANE2|(64/8))
+        sta     LCD_X
+        lda     #64
+        sta     LCD_Y
+        lda     #'z'
+        jsr     printsign
+
+        lda     #LCD_MODE_INC_Y|1
+        sta     LCD_MODE
+        lda     #16/8
+        sta     LCD_X
+        lda     #72
+        sta     LCD_Y
+        lda     #'V'
+        jsr     printsign
+
+        lda     #LCD_MODE_INC_Y|2
+        sta     LCD_MODE
+        lda     #24/8
+        sta     LCD_X
+        lda     #72
+        sta     LCD_Y
+        lda     #'V'
+        jsr     printsign
+
+        lda     #LCD_MODE_INC_Y|4
+        sta     LCD_MODE
+        lda     #32/8
+        sta     LCD_X
+        lda     #72
+        sta     LCD_Y
+        lda     #'V'
+        jsr     printsign
+
+        lda     #LCD_MODE_INC_Y|8
+        sta     LCD_MODE
+        lda     #40/8
+        sta     LCD_X
+        lda     #72
+        sta     LCD_Y
+        lda     #'V'
+        jsr     printsign
+
+        lda     #1
+        sta     ZP_IRQ_CTRL
+
+loop:
+        lda     count
         clc
-        adc    #1
-        sta count
-        lda count+1
-        adc    #1
-        sta count+1
-        lda irq_count
-        cmp irq_count
-        beq    loop
+        adc     #1
+        sta     count
+        lda     count+1
+        adc     #0
+        sta     count+1
 
-        jsr inputs
-        lda    #LCD_MODE_INC_Y
-        sta    LCD_MODE
-        jsr printy
+        lda     irq_count
+        cmp     irq_count
+        beq     loop
 
+        jsr     inputs
 
+        lda     #LCD_MODE_INC_Y
+        sta     LCD_MODE
+        jsr     printy
 
-        jmp loop
+        jmp     loop
 .endproc
 
 
 ;-------------------------------------------------------------------------------
 
 .proc printy
-        ldx    #0
-        ldy    #16
-        lda irq_count
-        jsr printhex
-
-        ldx    #3
-        ldy    #16
-        lda nmi_count
-        jsr printhex
-
-        ldx #6
-        ldy #16
-        lda counted+1
-        jsr printhex
-        ldx #8
-        ldy #16
-        lda counted
-        jsr printhex
-
-        ldx #11
-        ldy #16
-        lda xpos
-        jsr printhex
-        ldx #14
-        ldy #16
-        lda ypos
-        jsr printhex
+        ldx     #0
+        ldy     #16
+        lda     irq_count
+        jsr     printhex
+
+        ldx     #3
+        ldy     #16
+        lda     nmi_count
+        jsr     printhex
+
+        ldx     #6
+        ldy     #16
+        lda     counted+1
+        jsr     printhex
+        ldx     #8
+        ldy     #16
+        lda     counted
+        jsr     printhex
+
+        ldx     #11
+        ldy     #16
+        lda     xpos
+        jsr     printhex
+        ldx     #14
+        ldy     #16
+        lda     ypos
+        jsr     printhex
         rts
 .endproc
 
 .proc inputs
-        lda JOY_DATA
-        and #JOY_DATA_UP
-        bne notup
-        dec    ypos
-        lda ypos
-        sta LCD_YPOS
-notup:lda JOY_DATA
-        and #JOY_DATA_DOWN
-        bne notdown
-        inc ypos
-        lda ypos
-        sta LCD_YPOS
-notdown:lda JOY_DATA
-        and #JOY_DATA_LEFT
-        bne notleft
-        dec xpos
-        lda xpos
-        sta LCD_XPOS
-notleft:lda JOY_DATA
-        and #JOY_DATA_RIGHT
-        bne notright
-        inc xpos
-        lda xpos
-        sta LCD_XPOS
-notright:lda JOY_DATA
-        and #JOY_DATA_START
-        bne notstart
-notstart:lda JOY_DATA
-        and #JOY_DATA_SELECT
-        bne notselect
-notselect:lda JOY_DATA
-        and #JOY_DATA_FIRE_A
-        bne notbuttona
-notbuttona:lda JOY_DATA
-        and #JOY_DATA_FIRE_B
-        bne notbuttonb
-notbuttonb:rts
+        lda     JOY_DATA
+        and     #JOY_DATA_UP
+        bne     notup
+        dec     ypos
+        lda     ypos
+        sta     LCD_YPOS
+notup:
+        lda     JOY_DATA
+        and     #JOY_DATA_DOWN
+        bne     notdown
+        inc     ypos
+        lda     ypos
+        sta     LCD_YPOS
+notdown:
+        lda     JOY_DATA
+        and     #JOY_DATA_LEFT
+        bne     notleft
+        dec     xpos
+        lda     xpos
+        sta     LCD_XPOS
+notleft:
+        lda     JOY_DATA
+        and     #JOY_DATA_RIGHT
+        bne     notright
+        inc     xpos
+        lda     xpos
+        sta     LCD_XPOS
+notright:
+        lda     JOY_DATA
+        and     #JOY_DATA_START
+        bne     notstart
+notstart:
+        lda     JOY_DATA
+        and     #JOY_DATA_SELECT
+        bne     notselect
+notselect:
+        lda     JOY_DATA
+        and     #JOY_DATA_FIRE_A
+        bne     notbuttona
+notbuttona:
+        lda     JOY_DATA
+        and     #JOY_DATA_FIRE_B
+        bne     notbuttonb
+notbuttonb:
+        rts
 .endproc
 
 ;-------------------------------------------------------------------------------
 
 .proc printstring
-        sta    psa
-        stx psa+1
-        ldx #0
-        stx    psx
-        sty psy
+        sta     psa
+        stx     psa+1
+        ldx     #0
+        stx     psx
+        sty     psy
 printstring2:
-        ldy    #0
-        lda    (psa),y
-        beq printstring1
-        ldx psx
-        stx    LCD_X
-        ldy psy
-        sty    LCD_Y
-        jsr printsign
-        inc psx
-        lda psa
+        ldy     #0
+        lda     (psa),y
+        beq     printstring1
+        ldx     psx
+        stx     LCD_X
+        ldy      psy
+        sty     LCD_Y
+        jsr     printsign
+        inc     psx
+        lda     psa
         clc
-        adc    #1
-        sta psa
-        lda psa+1
-        adc    #0
-        sta psa+1
-        jmp printstring2
+        adc     #1
+        sta     psa
+        lda     psa+1
+        adc     #0
+        sta     psa+1
+        jmp     printstring2
 printstring1:
         rts
 .endproc
 
 .proc printstringy
-        sta    psa
-        stx psa+1
+        sta     psa
+        stx     psa+1
 printstring2:
-        ldy    #0
-        lda    (psa),y
-        beq printstring1
-        jsr printsign
-        lda psa
+        ldy     #0
+        lda     (psa),y
+        beq     printstring1
+        jsr     printsign
+        lda     psa
         clc
-        adc    #1
-        sta psa
-        lda psa+1
-        adc    #0
-        sta psa+1
-        jmp printstring2
+        adc     #1
+        sta     psa
+        lda     psa+1
+        adc     #0
+        sta     psa+1
+        jmp     printstring2
 printstring1:
         rts
 .endproc
@@ -340,24 +361,24 @@ printstring1:
         lsr
         lsr
         lsr
-        and #$0f
-        stx    temp_x
+        and     #$0f
+        stx     temp_x
         tax
-        lda    hex2asc,x
-        ldx    temp_x
-        stx    LCD_X
-        sty    LCD_Y
-        jsr    printsign
+        lda     hex2asc,x
+        ldx     temp_x
+        stx     LCD_X
+        sty     LCD_Y
+        jsr     printsign
         pla
-        and    #$0f
+        and     #$0f
         inx
-        stx    temp_x
+        stx     temp_x
         tax
-        lda    hex2asc,x
-        ldx    temp_x
-        stx    LCD_X
-        sty    LCD_Y
-        jmp printsign
+        lda     hex2asc,x
+        ldx     temp_x
+        stx     LCD_X
+        sty     LCD_Y
+        jmp     printsign
 .endproc
 
 .proc printsign