From: mrdudz Date: Sat, 14 Nov 2015 12:15:29 +0000 (+0100) Subject: initial import of the gamate stuff X-Git-Tag: V2.16~178^2~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=60285097e3b5bddc8c5ef67bd101039eae547763;p=cc65 initial import of the gamate stuff --- diff --git a/README.md b/README.md index 688b38029..49a5d01f3 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ including - the Atari 8 bit machines. - the Atari 5200 console. - GEOS for the C64, C128 and Apple //e. +- the Bit Corporation Gamate console. - the NEC PC-Engine (aka TurboGrafx-16). - the Nintendo Entertainment System (NES) console. - the Supervision console. diff --git a/asminc/gamate.inc b/asminc/gamate.inc new file mode 100644 index 000000000..bce86ead9 --- /dev/null +++ b/asminc/gamate.inc @@ -0,0 +1,43 @@ +; gamate symbols + +.p02 + +LCD_WIDTH = 160 +LCD_HEIGHT = 152 + +lcd_base = $5000 +lcd_mode = $5001 +lcd_mode_y_increment = $40 +lcd_x_pos = $5002 +lcd_x_pos_plane2_flag =$80 +lcd_y_pos = $5003 +lcd_x = $5004 +lcd_y = $5005 +lcd_read = $5006 +lcd_data = $5007 + +audio_base =$4000 + +controls = $4400 +; active low +up=1 +down=2 +left=4 +right=8 +button_a=$10 +button_b=$20 +start=$40 +select=$80 + +cart_main = $6020 +;cart_nmi = $6023 +cart_irq = $6026 ; 135 hz +cart_font = $6029 + +nmi_enable = $c +nmi_4800 = $a + +_f009 = $f009 ; wait 1/60s +_f00c = $f00c ; install font +_f012 = $f012 ; write screen + diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg new file mode 100644 index 000000000..5eac46c4b --- /dev/null +++ b/cfg/gamate.cfg @@ -0,0 +1,32 @@ +# c version of 32kbyte config file +# .data located in rom + +# ld65 config file +# ld65 --config gamate.cfg -o .bin .o + +MEMORY { + ZP: start = $0000, size = $100; + CPUSTACK: start = $0100, size =$100; + RAM: start = $0200, size = $200, define = yes; +# ROM: start = $6000, size = $8000, fill = yes, fillval = $ff, file = %O, define = yes; + ROM: start = $6000, size = $8000, fill = yes, fillval = $00, file = %O, define = yes; +} + +SEGMENTS { + CODE: load = ROM, type = ro, define=yes; + RODATA: load = ROM, type = ro, define=yes; + DATA: load = ROM, run=RAM, type = rw, define = yes; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp, define = yes; +} + +FEATURES { + CONDES: segment = RODATA, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = RODATA, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} diff --git a/doc/gamate.sgml b/doc/gamate.sgml new file mode 100644 index 000000000..227672b1b --- /dev/null +++ b/doc/gamate.sgml @@ -0,0 +1,154 @@ + + +
+ +Gamate System specific information for cc65 +<author> +<url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen"> +<date>2015-11-14 + +<abstract> +An overview over the Gamate runtime system as it is implemented for the +cc65 C compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Gamate runtime system as it comes +with the cc65 C compiler. It describes the memory layout, Gamate specific header +files, available drivers, and any pitfalls specific to that platform. + +Please note that Gamate specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more +information. + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the Gamate target +is a cartridge image with header. It is of course possible to change this +behaviour by using a modified startup file and linker config. + +<sect>Platform specific header files<p> + +Programs containing Gamate specific code may use the <tt/gamate.h/ header file. + + +<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/gamate.inc/ include file do +allow access to hardware located in the address space. + +<descrip> + +</descrip><p> + + + +<sect>Loadable drivers<p> + +All drivers must be statically linked because no file I/O is available. +The names in the parentheses denote the symbols to be used for static linking of the drivers. + + +<sect1>Graphics drivers<p> + +No TGI graphics drivers are currently available for the Gamate. + + +<sect1>Extended memory drivers<p> + +No extended memory drivers are currently available for the Gamate. + + +<sect1>Joystick drivers<p> + +<descrip> + + <tag><tt/gamate-stdjoy.joy (gamate_stdjoy)/</tag> + A joystick driver for the standard two buttons joypad is available. + +</descrip><p> + + +<sect1>Mouse drivers<p> + +No mouse drivers are currently available for the Gamate. + + +<sect1>RS232 device drivers<p> + +No serial drivers are currently available for the Gamate. + + + +<sect>Limitations<p> + +<itemize> +<item>interruptor support in crt0 (and cfg) is missing +</itemize> + +<sect1>Disk I/O<p> + +The existing library for the Gamate doesn't implement C file +I/O. There are no hacks for the <tt/read()/ and <tt/write()/ routines. + +To be more concrete, this limitation means that you cannot use any of the +following functions (and a few others): + +<itemize> +<item>printf +<item>fclose +<item>fopen +<item>fread +<item>fprintf +<item>fputc +<item>fscanf +<item>fwrite +<item>... +</itemize> + +<sect>Other hints<p> + +<itemize> +<item>a good emulator to use for Gamate is "MESS/MAME" (<url url="http://www.mess.org/">) +</itemize> + +some resources on the Gamate: + +<itemize> +<item><url url="http://en.wikipedia.org/wiki/Gamate"> +</itemize> + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> + + + diff --git a/doc/index.sgml b/doc/index.sgml index eb13c9af5..01ec61595 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -140,6 +140,9 @@ <tag><htmlurl url="pce.html" name="pce.html"></tag> Topics specific to NEC PC-Engine (TurboGrafx) Console. + <tag><htmlurl url="gamate.html" name="gamate.html"></tag> + Topics specific to Bit Corporation Gamate Console. + <tag><htmlurl url="pet.html" name="pet.html"></tag> Topics specific to the Commodore PET machines. diff --git a/include/conio.h b/include/conio.h index 8638e94d4..9eb68e565 100644 --- a/include/conio.h +++ b/include/conio.h @@ -69,6 +69,8 @@ # include <atmos.h> #elif defined(__CBM__) # include <cbm.h> +#elif defined(__GAMATE__) +# include <gamate.h> #elif defined(__GEOS__) # include <geos.h> #elif defined(__LUNIX__) diff --git a/include/gamate.h b/include/gamate.h new file mode 100644 index 000000000..3c141f0e9 --- /dev/null +++ b/include/gamate.h @@ -0,0 +1,43 @@ +/*****************************************************************************/ +/* */ +/* gamate.h */ +/* */ +/* Gamate system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2015 Groepaz/Hitmen */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + +#ifndef _GAMATE_H +#define _GAMATE_H + +/* Check for errors */ +#if !defined(__GAMATE__) +# error This module may only be used when compiling for the Gamate! +#endif + + + +/* End of gamate.h */ +#endif + diff --git a/include/time.h b/include/time.h index 12f130f52..33bcbb569 100644 --- a/include/time.h +++ b/include/time.h @@ -102,6 +102,9 @@ unsigned _clocks_per_sec (void); #elif defined(__PCE__) # 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 */ #elif defined(__GEOS__) # define CLK_TCK 1 /* POSIX */ # define CLOCKS_PER_SEC 1 /* ANSI */ diff --git a/libsrc/Makefile b/libsrc/Makefile index d70ad5a31..a4101aecd 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -22,6 +22,7 @@ TARGETS = apple2 \ atmos \ $(CBMS) \ $(GEOS) \ + gamate \ lynx \ nes \ osic1p \ diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/libsrc/gamate/crt0.s @@ -0,0 +1 @@ + diff --git a/src/ca65/main.c b/src/ca65/main.c index d81a87577..0016c46f3 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -264,6 +264,10 @@ static void SetSys (const char* Sys) NewSymbol ("__APPLE2ENH__", 1); break; + case TGT_GAMATE: + NewSymbol ("__GAMATE__", 1); + break; + case TGT_GEOS_CBM: /* Do not handle as a CBM system */ NewSymbol ("__GEOS__", 1); diff --git a/src/cc65/main.c b/src/cc65/main.c index 1041b8fa2..abe2af56e 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -220,6 +220,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__APPLE2ENH__", 1); break; + case TGT_GAMATE: + DefineNumericMacro ("__GAMATE__", 1); + break; + case TGT_GEOS_CBM: /* Do not handle as a CBM system */ DefineNumericMacro ("__GEOS__", 1); diff --git a/src/common/target.c b/src/common/target.c index 60b9af660..e89010123 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -154,6 +154,7 @@ static const TargetEntry TargetMap[] = { { "c64", TGT_C64 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, + { "gamate", TGT_GAMATE }, { "geos", TGT_GEOS_CBM }, { "geos-apple", TGT_GEOS_APPLE }, { "geos-cbm", TGT_GEOS_CBM }, @@ -204,6 +205,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim6502", CPU_6502, BINFMT_BINARY, CTNone }, { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, + { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 3ea562aa6..6366b725f 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -79,6 +79,7 @@ typedef enum { TGT_SIM6502, TGT_SIM65C02, TGT_PCENGINE, + TGT_GAMATE, TGT_COUNT /* Number of target systems */ } target_t; diff --git a/testcode/lib/gamate/Makefile b/testcode/lib/gamate/Makefile new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/testcode/lib/gamate/Makefile @@ -0,0 +1 @@ + diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s new file mode 100644 index 000000000..6d9670bca --- /dev/null +++ b/testcode/lib/gamate/audiotest.s @@ -0,0 +1,434 @@ +.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 +checksum: .word 0 + .byte 1,0,1 + .byte "COPYRIGHT BIT CORPORATION", 0, $ff + jmp reset + jmp nmi + jmp irq + +chars: +.incbin "cga2.chr" + +hex2asc: .byte "0123456789abcdef" + +.proc nmi + inc nmi_count + rts +.endproc + +.proc irq + inc irq_count + rts +.endproc + +.proc reset + 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_x_pos + sta lcd_y_pos + sta irq_count + sta cursor + lda #1 + sta nmi_count + cli + lda #lcd_mode_y_increment + sta lcd_mode + + jsr printy + + lda #1 + sta nmi_enable + +loop: + lda irq_count +loop1: + cmp irq_count + beq loop1 + lda irq_count + and #7 + bne loop1 + + lda #lcd_mode_y_increment + 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 +firstline: + sta lcd_x + sty lcd_y + lda #' ' + jsr printsign +norclearcursor: + + jsr inputs + + lda irq_count + and #8 + bne nocursor + lda cursor + ldy #0 + cmp #20 + bcc firstline2 + sec + sbc #20 + ldy #24 +firstline2: + sta lcd_x + sty lcd_y + lda #'x' + jsr printsign +nocursor: + + lda #lcd_mode_y_increment + sta lcd_mode + jsr printy + jmp loop +.endproc + +.proc printy + + ldy #0 +loop1: + tya + pha + asl + tax + lda readaddr,y + ldy #8 + jsr printhex + pla + tay + iny + cpy #10 + bne loop1 + +loop2: + tya + pha + tya + sec + sbc #10 + asl + tax + lda readaddr,y + ldy #16 + jsr printhex + pla + tay + iny + cpy #20 + bne loop2 + + ldx #0 + ldy #32 + lda nmi_count + jsr printhex + + rts +.endproc + +.proc inputs + lda controlslast + eor controls + and controlslast + eor #$ff + sta controlsedge + and #up + bne notup + + lda cursor + lsr + tay + bcs uplow + lda readaddr,y + clc + adc #$10 + sta readaddr,y + jmp notup +uplow:lda readaddr,y + clc + adc #1 + sta readaddr,y +notup:lda controlsedge + and #down + bne notdown + lda cursor + lsr + tay + bcs downlow + lda readaddr,y + sec + sbc #$10 + sta readaddr,y + jmp notdown +downlow: + lda readaddr,y + sec + sbc #1 + sta readaddr,y +notdown:lda controlsedge + and #left + bne notleft + lda cursor + beq notleft + dec cursor +notleft:lda controlsedge + and #right + bne notright + lda cursor + cmp #40 + beq notright + inc cursor +notright:lda controlsedge + and #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 #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 #button_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 + iny + cpy #16 + bne writeb +notbuttona:lda controlsedge + and #button_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 + iny + cpy #16 + bne readb +notbuttonb: + lda controls + sta controlslast + rts +.endproc + +.proc printstring + 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 + clc + adc #1 + sta psa + lda psa+1 + adc #0 + sta psa+1 + jmp printstring2 +printstring1: + rts +.endproc + +.proc printstringy + sta psa + stx psa+1 +printstring2: + 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 +printstring1: + rts +.endproc + + +.proc printhex + pha + lsr + lsr + lsr + lsr + and #$0f + stx temp_x + tax + lda hex2asc,x + ldx temp_x + stx lcd_x + sty lcd_y + jsr printsign + pla + and #$0f + inx + stx temp_x + tax + 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 + clc + adc #<chars + sta addr + lda addr+1 + adc #>chars + sta addr+1 + ldx #8 + ldy #0 +printsign1: + lda (addr),y + sta lcd_data + iny + dex + bne printsign1 + ldx temp_x + ldy temp_y + rts +.endproc + diff --git a/testcode/lib/gamate/cga2.chr b/testcode/lib/gamate/cga2.chr new file mode 100644 index 000000000..769f01f08 Binary files /dev/null and b/testcode/lib/gamate/cga2.chr differ diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s new file mode 100644 index 000000000..506016aad --- /dev/null +++ b/testcode/lib/gamate/lcdtest.s @@ -0,0 +1,383 @@ +.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 +checksum: .word 0 + .byte 1,0,1 + .byte "COPYRIGHT BIT CORPORATION", 0, $ff + jmp reset + jmp nmi + jmp irq + +chars: +.incbin "cga2.chr" + +hex2asc: .byte "0123456789abcdef" +format: .byte "IrqNmiCountXposYpos", 0 +xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0 +ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 + +.proc nmi + inc nmi_count + rts +.endproc + +.proc irq + inc irq_count + lda count + sta counted + lda count+1 + sta counted+1 + lda #0 + sta count + sta count+1 + rts +.endproc + +.proc reset + lda #0 + sta lcd_x_pos + sta lcd_y_pos + cli + lda #lcd_mode_y_increment + sta lcd_mode + + lda #0 + sta lcd_x + lda #<xdesc + ldx #>xdesc + ldy #0 + jsr printstring + + lda #lcd_x_pos_plane2_flag + sta lcd_x + lda #<xdesc + ldx #>xdesc + ldy #128 + jsr printstring + + lda #0 + sta lcd_x + lda #<ydesc + ldx #>ydesc + ldy #0 + sty lcd_y + jsr printstringy + +; lda #$90;(lcd_x_pos_plane2_flag|(128/8)) + lda #(lcd_x_pos_plane2_flag|(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_x_pos_plane2_flag|(48/8) + sta lcd_x + lda #48 + sta lcd_y + lda #'x' + jsr printsign + lda #$80 + sta lcd_mode + lda #(lcd_x_pos_plane2_flag|(56/8)) + sta lcd_x + lda #56 + sta lcd_y + lda #'y' + jsr printsign + lda #$c0 + sta lcd_mode + lda #(lcd_x_pos_plane2_flag|(64/8)) + sta lcd_x + lda #64 + sta lcd_y + lda #'z' + jsr printsign + + lda #lcd_mode_y_increment|1 + sta lcd_mode + lda #16/8 + sta lcd_x + lda #72 + sta lcd_y + lda #'V' + jsr printsign + lda #lcd_mode_y_increment|2 + sta lcd_mode + lda #24/8 + sta lcd_x + lda #72 + sta lcd_y + lda #'V' + jsr printsign + lda #lcd_mode_y_increment|4 + sta lcd_mode + lda #32/8 + sta lcd_x + lda #72 + sta lcd_y + lda #'V' + jsr printsign + lda #lcd_mode_y_increment|8 + sta lcd_mode + lda #40/8 + sta lcd_x + lda #72 + sta lcd_y + lda #'V' + jsr printsign + + lda #1 + sta nmi_enable + +loop: lda count + clc + adc #1 + sta count + lda count+1 + adc #1 + sta count+1 + lda irq_count + cmp irq_count + beq loop + + jsr inputs + lda #lcd_mode_y_increment + sta lcd_mode + jsr printy + + + + 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 + rts +.endproc + +.proc inputs + lda controls + and #up + bne notup + dec ypos + lda ypos + sta lcd_y_pos +notup:lda controls + and #down + bne notdown + inc ypos + lda ypos + sta lcd_y_pos +notdown:lda controls + and #left + bne notleft + dec xpos + lda xpos + sta lcd_x_pos +notleft:lda controls + and #right + bne notright + inc xpos + lda xpos + sta lcd_x_pos +notright:lda controls + and #start + bne notstart +notstart:lda controls + and #select + bne notselect +notselect:lda controls + and #button_a + bne notbuttona +notbuttona:lda controls + and #button_b + bne notbuttonb +notbuttonb:rts +.endproc + +.proc printstring + 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 + clc + adc #1 + sta psa + lda psa+1 + adc #0 + sta psa+1 + jmp printstring2 +printstring1: + rts +.endproc + +.proc printstringy + sta psa + stx psa+1 +printstring2: + 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 +printstring1: + rts +.endproc + + +.proc printhex + pha + lsr + lsr + lsr + lsr + and #$0f + stx temp_x + tax + lda hex2asc,x + ldx temp_x + stx lcd_x + sty lcd_y + jsr printsign + pla + and #$0f + inx + stx temp_x + tax + 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 + clc + adc #<chars + sta addr + lda addr+1 + adc #>chars + sta addr+1 + ldx #8 + ldy #0 +printsign1: + lda (addr),y + sta lcd_data + iny + dex + bne printsign1 + ldx temp_x + ldy temp_y + rts +.endproc +