From 60285097e3b5bddc8c5ef67bd101039eae547763 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 14 Nov 2015 13:15:29 +0100 Subject: [PATCH 01/16] initial import of the gamate stuff --- README.md | 1 + asminc/gamate.inc | 43 ++++ cfg/gamate.cfg | 32 +++ doc/gamate.sgml | 154 ++++++++++++ doc/index.sgml | 3 + include/conio.h | 2 + include/gamate.h | 43 ++++ include/time.h | 3 + libsrc/Makefile | 1 + libsrc/gamate/crt0.s | 1 + src/ca65/main.c | 4 + src/cc65/main.c | 4 + src/common/target.c | 2 + src/common/target.h | 1 + testcode/lib/gamate/Makefile | 1 + testcode/lib/gamate/audiotest.s | 434 ++++++++++++++++++++++++++++++++ testcode/lib/gamate/cga2.chr | Bin 0 -> 2048 bytes testcode/lib/gamate/lcdtest.s | 383 ++++++++++++++++++++++++++++ 18 files changed, 1112 insertions(+) create mode 100644 asminc/gamate.inc create mode 100644 cfg/gamate.cfg create mode 100644 doc/gamate.sgml create mode 100644 include/gamate.h create mode 100644 libsrc/gamate/crt0.s create mode 100644 testcode/lib/gamate/Makefile create mode 100644 testcode/lib/gamate/audiotest.s create mode 100644 testcode/lib/gamate/cga2.chr create mode 100644 testcode/lib/gamate/lcdtest.s 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 0000000000000000000000000000000000000000..769f01f08889b4da91ef1810fa6ec86784486708 GIT binary patch literal 2048 zcmYLKKWpqp5FZ?H8ezL!@L@xEA7F`ttwP+v`wr<B`?2p83%TmD5Jk4T6!`%02S}4T ztwC_0q*(kqW4PnE>fAicRkjF1%I~+*C3BWWGdug6KRY`X>8ZH={r3LuwkWzqH-GL5 z*S2k*9?4OfN1o<s+ddwpM^SN<il{78B3<`9hkYlRegEEO(#`Mg@9*Z_;n#;hhY);b zt<6-SCTA0^r`z@Q)%DfY$4#jg+4FO@P&ezkt=BiQcQ9_p2YWy*lqxcXZPtpF>&4=y z<Ktr)U!~5a!86*TD54$Ax@fPIC=g_Xm9z<%Xww=^>#{6cuy?kz@4&GE(K7I8j;~1C zd#y!_b1urxwfH&FdFhiHKvhuMR+74OwhS{dri^w<8)LK*JPO|;HtRBrC9N9(_N2KW z%^-12_7hl_H<DKmtJh5~da6N<_>iO~^gKbjqs)aiIgzHU6UwP6Ym`-*007{42$b>4 z6E%(4#2+3*FN`m`M+Eq$XZlghH?LN!Rp~_opb0@5YjbNG94G3A^Q;}t!PU}Ue)69# z+n$?kTz{}*!5L#)5L6H3<s?Cvh-YJ+cXlINl;_g6QoW#ks!FQO>*@hKbyZclH2O2Z zgZr@bqbPHq4~Ud`{@LSV8Pw1p;I&})WBUR;fB=hngy5yEepTPXpNC&#yfFD>e@{Fc zM0xZxjQ^)j$J$WglN{%|HU{}GDTfmNM+wx>Q*KbF)ET6-g*;=$>$Pz+i+Ht6WB!Ts z1y~yvU=y{BOC+!W;59Rdc&wAi5)~(4#5;jJvk^Zwo*e01>+g7e+{QS-kUtvov2EF_ zC_qdJdc=cs{!M>qWTf?4>k;ood?-LAGp0sjAu7~~S*pZKAaEh0A<tr-?T_sQYSyKY z^}vx!lu?foHzS3eElftcSRdF$9)^14Rf-TY?C<MS!EKB4kFDDT_-l+eyc*ZZb-0!> z+C78^px}@7*>M6xhCap#z@Ae^-gA|4(DZ4*4%474F-lVRVQV(*8{hCoqWb?-pR2zP zj#Z}A(-ir}e9|GlSOEGR4fu6DFkIg7rCA2aoEu9a=mRuwj%$WN!#)8uWl1JYl8DT! zusXBh5PWg*!{@Jt5hVhpJ%bhA7H#m&Fa7WPKl<O|$HfaD6zxB%<5#W7&q1$v=%|f+ zr+?k2en(gx<kx+UKkCU9P|zfidR(PWqh2YFMN$|2K@T2fyr}B+r%_M53%<@T^n^w- z(Y^d8Jx(WY!#edqjr#NRx2UH#+R<cZPkbVEao_nlaT&!amD2m=*JN0y9i!UCyUUAl zcLUL$pWA^B2cnK^xOdCHm$+9x)S<=+HUWdLMEUTa0Q0}W9O692f1RhNrzz$;C^sdx zu_V%PaC+Uuwnj_vRyp^A`=>BBJohaY=$HM3+?1T(rAgV$By>ys;Xa@_@riMT>D&n3 zm`sfv93Rt9PY56yalYds^Df6egcnd>JbvIg#2EVGvXPHjh)e;<Xhbql{D`lA0hU77 AoB#j- literal 0 HcmV?d00001 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 + From 88e7b5776a07d01b09a3743b7e029a6697ef7caf Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 22 Nov 2015 19:02:47 +0100 Subject: [PATCH 02/16] some more fiddling --- asminc/gamate.inc | 2 +- cfg/gamate.cfg | 11 ++++++++++- libsrc/gamate/crt0.s | 17 ++++++++++++++++- src/common/target.c | 2 +- testcode/lib/gamate/Makefile | 22 +++++++++++++++++++++- testcode/lib/gamate/audiotest.s | 9 +++------ testcode/lib/gamate/lcdtest.s | 14 +++++++------- 7 files changed, 59 insertions(+), 18 deletions(-) diff --git a/asminc/gamate.inc b/asminc/gamate.inc index bce86ead9..fda288e5f 100644 --- a/asminc/gamate.inc +++ b/asminc/gamate.inc @@ -1,6 +1,6 @@ ; gamate symbols -.p02 +;.p02 LCD_WIDTH = 160 LCD_HEIGHT = 152 diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index 5eac46c4b..c6f2eed7d 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -4,20 +4,29 @@ # ld65 config file # ld65 --config gamate.cfg -o <prog>.bin <prog>.o +SYMBOLS { + __STARTUP__: type = import; + __STACKSIZE__: type = weak, value = $0300; # 3 pages stack +} + 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; +# STARTUP: file = %O, define = yes, start = $6000, size = $29, fill = yes; +# ROM: start = $6000 + __STARTUP_SIZE__, size = $8000 - __STARTUP_SIZE__, fill = yes, fillval = $ff, file = %O, define = yes; +# WARNING: fill value must be $00 else it will no more work ROM: start = $6000, size = $8000, fill = yes, fillval = $00, file = %O, define = yes; } SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + STARTUP: load = ROM, type = ro, define=yes; 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 { diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index 8d1c8b69c..66ff8054c 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -1 +1,16 @@ - + + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import reset, irq, nmi ; FIXME + + + .segment "STARTUP" + +checksum: + .word 0 + .byte 1, 0, 1 + .byte "COPYRIGHT BIT CORPORATION", 0, $ff + jmp reset + jmp nmi + jmp irq + diff --git a/src/common/target.c b/src/common/target.c index e89010123..ebd05cbf1 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -205,7 +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 }, + { "gamate", CPU_65C02, BINFMT_BINARY, CTNone }, }; /* Target system */ diff --git a/testcode/lib/gamate/Makefile b/testcode/lib/gamate/Makefile index 8d1c8b69c..943f6c195 100644 --- a/testcode/lib/gamate/Makefile +++ b/testcode/lib/gamate/Makefile @@ -1 +1,21 @@ - + +all: audiotest.bin lcdtest.bin + +audiotest.bin: audiotest.s +# ../../../bin/ca65 -t gamate -o audiotest.o audiotest.s +# ../../../bin/ld65 -t gamate -o audiotest.bin audiotest.o + ../../../bin/cl65 -t gamate -o audiotest.bin audiotest.s + +lcdtest.bin: lcdtest.s +# ../../../bin/ca65 -t gamate -o lcdtest.o lcdtest.s +# ../../../bin/ld65 -t gamate -o lcdtest.bin lcdtest.o + ../../../bin/cl65 -l bla.lst -t gamate -o lcdtest.bin lcdtest.s + +test1: lcdtest.bin + cd /home/groepaz/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart /home/groepaz/Desktop/cc65/github/cc65/testcode/lib/gamate/lcdtest.bin +test2: audiotest.bin + cd /home/groepaz/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart /home/groepaz/Desktop/cc65/github/cc65/testcode/lib/gamate/audiotest.bin + +clean: + rm -f lcdtest.o audiotest.o + rm -f lcdtest.bin audiotest.bin diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index 6d9670bca..a5b2143ce 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -1,3 +1,6 @@ + + .export reset, irq, nmi ; FIXME + .include "gamate.inc" .zeropage addr: .word 0 @@ -25,12 +28,6 @@ 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" diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index 506016aad..b4798c677 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -1,4 +1,9 @@ + + .export reset, irq, nmi ; FIXME + + .include "gamate.inc" + .zeropage addr: .word 0 psa: .word 0 @@ -17,12 +22,6 @@ 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" @@ -37,6 +36,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 rts .endproc + .proc irq inc irq_count lda count @@ -88,7 +88,6 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 sty lcd_y jsr printstringy - lda #<format ldx #>format ldy #8 @@ -177,6 +176,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 lda #'V' jsr printsign + lda #1 sta nmi_enable From 9fbf8a4299865c3bef3adb0794680c06dfb7a6b7 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 01:14:59 +0100 Subject: [PATCH 03/16] conio and most other stuff working now --- asminc/gamate.inc | 95 +++-- cfg/gamate.cfg | 56 ++- include/gamate.h | 140 ++++++- libsrc/gamate/_scrsize.s | 16 + libsrc/gamate/chline.s | 32 ++ libsrc/gamate/clock.s | 33 ++ libsrc/gamate/clrscr.s | 35 ++ libsrc/gamate/color.s | 34 ++ libsrc/gamate/conio.s | 31 ++ libsrc/gamate/cputc.s | 153 +++++++ libsrc/gamate/crt0.s | 78 +++- libsrc/gamate/ctype.s | 161 +++++++ libsrc/gamate/cvline.s | 32 ++ libsrc/gamate/extzp.inc | 16 + libsrc/gamate/extzp.s | 16 + libsrc/gamate/gotoxy.s | 22 + libsrc/gamate/irq.s | 51 +++ libsrc/gamate/joy/gamate-stdjoy.s | 95 +++++ libsrc/gamate/joy_stat_stddrv.s | 14 + libsrc/gamate/joy_stddrv.s | 13 + libsrc/gamate/kplot.s | 32 ++ libsrc/gamate/libref.s | 8 + libsrc/gamate/revers.s | 28 ++ libsrc/gamate/ticktock.s | 17 + libsrc/gamate/vga.inc | 228 ++++++++++ libsrc/gamate/waitvblank.s | 20 + libsrc/gamate/wherex.s | 20 + libsrc/gamate/wherey.s | 20 + src/common/target.c | 2 +- testcode/lib/conio.c | 31 +- testcode/lib/gamate/Makefile | 23 +- testcode/lib/gamate/audiotest.s | 675 +++++++++++++++--------------- testcode/lib/gamate/ctest.c | 52 +++ testcode/lib/gamate/lcdtest.s | 638 ++++++++++++++-------------- util/gamate/gamate-fixcart.c | 25 ++ 35 files changed, 2205 insertions(+), 737 deletions(-) create mode 100644 libsrc/gamate/_scrsize.s create mode 100644 libsrc/gamate/chline.s create mode 100644 libsrc/gamate/clock.s create mode 100644 libsrc/gamate/clrscr.s create mode 100644 libsrc/gamate/color.s create mode 100644 libsrc/gamate/conio.s create mode 100644 libsrc/gamate/cputc.s create mode 100644 libsrc/gamate/ctype.s create mode 100644 libsrc/gamate/cvline.s create mode 100644 libsrc/gamate/extzp.inc create mode 100644 libsrc/gamate/extzp.s create mode 100644 libsrc/gamate/gotoxy.s create mode 100644 libsrc/gamate/irq.s create mode 100644 libsrc/gamate/joy/gamate-stdjoy.s create mode 100644 libsrc/gamate/joy_stat_stddrv.s create mode 100644 libsrc/gamate/joy_stddrv.s create mode 100644 libsrc/gamate/kplot.s create mode 100644 libsrc/gamate/libref.s create mode 100644 libsrc/gamate/revers.s create mode 100644 libsrc/gamate/ticktock.s create mode 100644 libsrc/gamate/vga.inc create mode 100644 libsrc/gamate/waitvblank.s create mode 100644 libsrc/gamate/wherex.s create mode 100644 libsrc/gamate/wherey.s create mode 100644 testcode/lib/gamate/ctest.c create mode 100644 util/gamate/gamate-fixcart.c diff --git a/asminc/gamate.inc b/asminc/gamate.inc index fda288e5f..167c9b1e1 100644 --- a/asminc/gamate.inc +++ b/asminc/gamate.inc @@ -1,43 +1,70 @@ -; gamate symbols +;------------------------------------------------------------------------------- +; gamate.inc +; +; Gamate system specific definitions +; +; (w) 2015 Groepaz/Hitmen (groepaz@gmx.net) +; based on technical reference by PeT (mess@utanet.at) +;------------------------------------------------------------------------------- -;.p02 +; look at gamate.h for comments, they are not duplicated here -LCD_WIDTH = 160 -LCD_HEIGHT = 152 +AUDIO_BASE = $4000 -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 +JOY_DATA = $4400 -audio_base =$4000 +JOY_DATA_UP = $01 +JOY_DATA_DOWN = $02 +JOY_DATA_LEFT = $04 +JOY_DATA_RIGHT = $08 +JOY_DATA_FIRE_A = $10 +JOY_DATA_FIRE_B = $20 +JOY_DATA_START = $40 +JOY_DATA_SELECT = $80 -controls = $4400 -; active low -up=1 -down=2 -left=4 -right=8 -button_a=$10 -button_b=$20 -start=$40 -select=$80 +LCD_WIDTH = 160 +LCD_HEIGHT = 152 -cart_main = $6020 -;cart_nmi = $6023 -cart_irq = $6026 ; 135 hz -cart_font = $6029 +LCD_BASE = $5000 +LCD_MODE = $5001 +LCD_XPOS = $5002 +LCD_YPOS = $5003 +LCD_X = $5004 +LCD_Y = $5005 +LCD_READ = $5006 +LCD_DATA = $5007 -nmi_enable = $c -nmi_4800 = $a +LCD_MODE_INC_X = $00 +LCD_MODE_INC_Y = $40 +LCD_XPOS_PLANE1 = $00 +LCD_XPOS_PLANE2 = $80 -_f009 = $f009 ; wait 1/60s -_f00c = $f00c ; install font -_f012 = $f012 ; write screen +; constants for the conio implementation +charsperline = (LCD_WIDTH / 8) +screenrows = (LCD_HEIGHT / 8) + +CH_HLINE = 1 +CH_VLINE = 2 + +COLOR_WHITE = 0 +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 diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index c6f2eed7d..577dfeb1d 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -1,41 +1,39 @@ -# c version of 32kbyte config file -# .data located in rom - -# ld65 config file -# ld65 --config gamate.cfg -o <prog>.bin <prog>.o +# linker config to produce simple Gamate cartridge (.bin) SYMBOLS { - __STARTUP__: type = import; - __STACKSIZE__: type = weak, value = $0300; # 3 pages stack + __STARTUP__: type = import; + __STACKSIZE__: type = weak, value = $0080; # 1 page stack } 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; -# STARTUP: file = %O, define = yes, start = $6000, size = $29, fill = yes; -# ROM: start = $6000 + __STARTUP_SIZE__, size = $8000 - __STARTUP_SIZE__, fill = yes, fillval = $ff, file = %O, define = yes; -# WARNING: fill value must be $00 else it will no more work - ROM: start = $6000, size = $8000, fill = yes, fillval = $00, file = %O, define = yes; + # 0000-03ff is RAM + # FIXME: what zp range can we actually use? + ZP: start = $0080, size = $80; + CPUSTACK: start = $0100, size =$100; + RAM: start = $0200, size = $180, define = yes; + + # 6000-e000 can be (Cartridge) ROM + # WARNING: fill value must be $00 else it will no more work + #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; + #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; + # for images that have code >$6fff we must calculate the checksum! + ROM: start = $6000, size = $8000, fill = yes, fillval = $00, file = %O, define = yes; } SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - STARTUP: load = ROM, type = ro, define=yes; - 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; + EXTZP: load = ZP, type = zp, define = yes, optional = yes; + APPZP: load = ZP, type = zp, define = yes, optional = yes; + STARTUP: load = ROM, type = ro, define=yes; + INIT: load = ROM, type = ro, define = yes, optional = yes; + 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; } FEATURES { - CONDES: segment = RODATA, - type = constructor, - label = __CONSTRUCTOR_TABLE__, - count = __CONSTRUCTOR_COUNT__; - CONDES: segment = RODATA, - type = destructor, - label = __DESTRUCTOR_TABLE__, - count = __DESTRUCTOR_COUNT__; + CONDES: segment = RODATA, type = constructor, label = __CONSTRUCTOR_TABLE__, count = __CONSTRUCTOR_COUNT__; + CONDES: segment = RODATA, type = destructor, label = __DESTRUCTOR_TABLE__, count = __DESTRUCTOR_COUNT__; + CONDES: segment = RODATA, type = interruptor, label = __INTERRUPTOR_TABLE__, count = __INTERRUPTOR_COUNT__, import = __CALLIRQ__; } diff --git a/include/gamate.h b/include/gamate.h index 3c141f0e9..f89f5204e 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -6,8 +6,8 @@ /* */ /* */ /* */ -/* (C) 2015 Groepaz/Hitmen */ -/* */ +/* (w) 2015 Groepaz/Hitmen (groepaz@gmx.net) */ +/* based on technical reference by PeT (mess@utanet.at) */ /* */ /* This software is provided 'as-is', without any expressed or implied */ /* warranty. In no event will the authors be held liable for any damages */ @@ -36,7 +36,143 @@ # error This module may only be used when compiling for the Gamate! #endif +#define AUDIO_BASE 0x4000 +/* + 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) + (delay clock/32) +2/3: 2. channel(left): 12 bit frequency +4/5: 3. channel(both): 12 bit frequency +6: 0..5 noise frequency 0 fast 1f slow (about 500us) 15.6ns--> clock/32 counts +7 control (hinibble right) + bit 0: right channel high (full cycle, else square pulse/tone) + bit 1: left channel high + bit 2: both channel high + bit 3: set right tone (else noise) + bit 4: set left channel normal + bit 5: set both normal + bits 30: 11 high, 10 square, 01 noise, 00 noise only when square high + noise means switches channel to ad converter based noise algorithmen + (white noise shift register 17bit wide, repeats after about 130000 cycles) + probably out=!bit16, bit0=bit16 xor bit13; runs through, so start value anything than 0 +8: 1st volume: 0..3 square volume; bit 4 envelope (higher priority) +9: 2nd volume +10: 3rd volume +11/12: envelope delay time 0 fast, 0xffff slow/nearly no effect (2 22us, 4 56us) + frequency $800, envelope $10 2 times in pulse high time (4*16*16) +13: envelope control + 0-3 one time falling + 4-7 one time rising + 8 falling + 9 one time falling + a starts with down falling, rising; same falling time, but double/longer cycle + b one time falling, on + c rising + d one time rising, on + e rising, falling (double cycle before restart) + f one time rising + bit 0: once only + bit 1: full tone + bit 2: start rising (else falling) + bit 3: +*/ + +#define JOY_DATA 0x4400 + +#define JOY_DATA_UP 0x01 +#define JOY_DATA_DOWN 0x02 +#define JOY_DATA_LEFT 0x04 +#define JOY_DATA_RIGHT 0x08 +#define JOY_DATA_FIRE_A 0x10 +#define JOY_DATA_FIRE_B 0x20 +#define JOY_DATA_START 0x40 +#define JOY_DATA_SELECT 0x80 + +/* LCD + + resolution 160x152 in 4 greys/greens + 2 256x256 sized bitplanes (2x 8kbyte ram) +*/ +#define LCD_BASE 0x5000 + +#define LCD_MODE 0x5001 +/* + bit 3..0 (from zeropage 15) + bit 0 set no normal screen display, seldom scrolling effects on screen; + bytes written to somewhat actual display refresh position!? + bytes read "random" + bit 1,2,3 no effect + bit 4 swaps plane intensity + bit 5 ? display effect + bit 6 on y auto increment (else auto x increment), reading + bit 7 ? lcd flickering +*/ +#define LCD_MODE_INC_Y 0x40 + +#define LCD_XPOS 0x5002 /* smooth scrolling X */ +#define LCD_YPOS 0x5003 /* smooth scrolling Y */ +/* + smooth scrolling until $c8 with 200 limit + after 200 display if ((value & 0xf) < 8) display of (value & 0xf) - 8 + chaos lines from value + current line from plane 2 only then lines starting + with zero (problematic 200 limit/overrun implementation!?) +*/ +#define LCD_X 0x5004 /* x-addr */ +/* + bit 5,6 no effect + bit 7 0 1st/1 2nd bitplane +*/ +#define LCD_XPOS_PLANE1 0x00 +#define LCD_XPOS_PLANE2 0x80 + +#define LCD_Y 0x5005 /* y-addr */ + +#define LCD_READ 0x5006 /* read from RAM (no auto inc?) */ +#define LCD_DATA 0x5007 /* write to RAM */ + + +/* constants for the conio implementation */ +#define COLOR_BLACK 0x03 +#define COLOR_WHITE 0x00 + +#define CH_HLINE 1 +#define CH_VLINE 2 +#define CH_CROSS 3 +#define CH_ULCORNER 4 +#define CH_URCORNER 5 +#define CH_LLCORNER 6 +#define CH_LRCORNER 7 +#define CH_TTEE 8 +#define CH_BTEE 9 + +#define CH_RTEE 11 +#define CH_LTEE 12 + +#define CH_ENTER 13 +#define CH_PI 18 + +#define TV_NTSC 0 +#define TV_PAL 1 +#define TV_OTHER 2 + +/* No support for dynamically loadable drivers */ +#define DYN_DRV 0 + +/* The addresses of the static drivers */ +extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ + +#define JOY_FIRE_B 5 +#define JOY_START 6 +#define JOY_SELECT 7 + +void waitvblank (void); +/* Wait for the vertical blanking */ + +/* NOTE: all Gamate are "NTSC" */ +#define get_tv() TV_NTSC +/* Return the video mode the machine is using. */ /* End of gamate.h */ #endif diff --git a/libsrc/gamate/_scrsize.s b/libsrc/gamate/_scrsize.s new file mode 100644 index 000000000..f26f22d2b --- /dev/null +++ b/libsrc/gamate/_scrsize.s @@ -0,0 +1,16 @@ +; +; Screen size variables +; + .include "gamate.inc" + + .export screensize +screensize: + ldx xsize + ldy ysize + rts + +.rodata + .export xsize, ysize + +xsize: .byte charsperline +ysize: .byte screenrows diff --git a/libsrc/gamate/chline.s b/libsrc/gamate/chline.s new file mode 100644 index 000000000..2d96c9d2f --- /dev/null +++ b/libsrc/gamate/chline.s @@ -0,0 +1,32 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; +; void chlinexy (unsigned char x, unsigned char y, unsigned char length); +; void chline (unsigned char length); +; + + .export _chlinexy, _chline + .import popa, _gotoxy, cputdirect + .importzp tmp1 + + .include "gamate.inc" + +_chlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length + +_chline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #CH_HLINE ; Horizontal line, screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts + + + + diff --git a/libsrc/gamate/clock.s b/libsrc/gamate/clock.s new file mode 100644 index 000000000..223c07967 --- /dev/null +++ b/libsrc/gamate/clock.s @@ -0,0 +1,33 @@ +; +; clock_t clock (void); +; + + .include "gamate.inc" + .include "extzp.inc" + + .export _clock + .forceimport ticktock + .importzp sreg + .constructor initclock + + +.proc _clock + + lda tickcount+3 + sta sreg+1 + lda tickcount+2 + sta sreg + ldx tickcount+1 + lda tickcount + rts + +.endproc + + .segment "INIT" +initclock: + lda #0 + ldx #3 +@lp: sta tickcount,x + dex + bpl @lp + rts diff --git a/libsrc/gamate/clrscr.s b/libsrc/gamate/clrscr.s new file mode 100644 index 000000000..c96fc4eda --- /dev/null +++ b/libsrc/gamate/clrscr.s @@ -0,0 +1,35 @@ + + .include "gamate.inc" + .include "extzp.inc" + + .import plot + .export _clrscr +_clrscr: + ldy #$0 +rowloop: + sty LCD_X + + lda #0 + sta LCD_Y + + ldx #$0 +colloop: + sta LCD_DATA + + inx + bne colloop + + iny + bne rowloop + +; Go to the home position. + + sta CURS_X + sta CURS_Y + jmp plot + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/gamate/color.s b/libsrc/gamate/color.s new file mode 100644 index 000000000..07bc25af9 --- /dev/null +++ b/libsrc/gamate/color.s @@ -0,0 +1,34 @@ +; +; unsigned char __fastcall__ textcolor (unsigned char color); +; unsigned char __fastcall__ bgcolor (unsigned char color); +; unsigned char __fastcall__ bordercolor (unsigned char color); +; + + + .export _textcolor, _bgcolor, _bordercolor + + .include "gamate.inc" + .include "extzp.inc" + +_textcolor: + ldx CHARCOLOR ; get old value + sta CHARCOLOR ; set new value + txa + rts + +_bgcolor: + ldx BGCOLOR ; get old value + sta BGCOLOR ; set new value + txa + rts + +_bordercolor: + lda #0 + tax + rts + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/gamate/conio.s b/libsrc/gamate/conio.s new file mode 100644 index 000000000..4840b372c --- /dev/null +++ b/libsrc/gamate/conio.s @@ -0,0 +1,31 @@ + .include "gamate.inc" + .include "extzp.inc" + + .import colors + .importzp ptr1, tmp1 + + .constructor initconio + + .macpack longbranch + + .segment "INIT" +initconio: + ; FIXME + lda #0 + sta LCD_XPOS + sta LCD_YPOS + + lda #LCD_MODE_INC_Y + sta LCD_MODE + + lda #COLOR_BLACK + sta CHARCOLOR + lda #COLOR_WHITE + sta BGCOLOR + rts + + .segment "RODATA" + + .export fontdata +fontdata: + .include "vga.inc" diff --git a/libsrc/gamate/cputc.s b/libsrc/gamate/cputc.s new file mode 100644 index 000000000..0ebd659b2 --- /dev/null +++ b/libsrc/gamate/cputc.s @@ -0,0 +1,153 @@ +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .export _cputcxy, _cputc, cputdirect, putchar + .export newline, plot + .import popa, _gotoxy + .import PLOT + .import xsize + .import fontdata + .import _plotlo + + .importzp tmp3,tmp4 + .importzp ptr3 + + .include "gamate.inc" + .include "extzp.inc" + +_cputcxy: + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy ; Set cursor, drop x + pla ; Restore C + +; Plot a character - also used as internal function + +_cputc: cmp #$0d ; CR? + bne L1 + lda #0 + sta CURS_X + beq plot ; Recalculate pointers + +L1: cmp #$0a ; LF? + beq newline ; Recalculate pointers + +; Printable char of some sort + +cputdirect: + jsr putchar ; Write the character to the screen + +; Advance cursor position + +advance: + ldy CURS_X + iny + cpy xsize + bne L3 + jsr newline ; new line + ldy #0 ; + cr +L3: sty CURS_X + jmp plot + +newline: + inc CURS_Y + +; Set cursor position, calculate RAM pointers + +plot: ldy CURS_X + ldx CURS_Y + clc + jmp PLOT ; Set the new cursor + +; Write one character to the screen without doing anything else, return 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 + pha + + lda #0 + sta ptr3+1 + ; * 8 + asl ptr3 + rol ptr3+1 + asl ptr3 + rol ptr3+1 + asl ptr3 + rol ptr3+1 + + lda ptr3 + clc + adc #<(fontdata-$f8) + sta ptr3 + lda ptr3+1 + adc #>(fontdata-$f8) + sta ptr3+1 + + lda CHARCOLOR + and #1 + beq @skip_plane1 + + lda #LCD_XPOS_PLANE1 + clc + adc CURS_X + sta LCD_X + + ldy #$f8 +@copylp1: + lda (ptr3),y + eor RVS + sta LCD_DATA + iny + bne @copylp1 + +@skip_plane1: + + lda CHARCOLOR + and #2 + beq @skip_plane2 + + lda #LCD_XPOS_PLANE2 + clc + adc CURS_X + sta LCD_X + + ldx CURS_Y + lda _plotlo,x + sta LCD_Y + + ldy #$f8 +@copylp2: + lda (ptr3),y + eor RVS + sta LCD_DATA + iny + bne @copylp2 + +@skip_plane2: + + + pla + tax + ldy CURS_X + rts + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index 66ff8054c..b54d8ade1 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -1,16 +1,78 @@ .export __STARTUP__ : absolute = 1 ; Mark as startup - .import reset, irq, nmi ; FIXME + .import initlib, donelib, callmain + .import push0, _main, zerobss, copydata + .import IRQStub + + ; Linker generated symbols + .import __RAM_START__, __RAM_SIZE__ + .import __ROM_START__, __ROM_SIZE__ + .import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ + .import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ + .import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ + + .include "zeropage.inc" + .include "gamate.inc" .segment "STARTUP" -checksum: - .word 0 - .byte 1, 0, 1 - .byte "COPYRIGHT BIT CORPORATION", 0, $ff - jmp reset - jmp nmi - jmp irq + .word 0 ; +00 checksum from 7000-7fff (simple 8bit adds) + .byte 1, 0, 1 ; +02 flags + .byte "COPYRIGHT BIT CORPORATION", 0, $ff ; +05 copyright + ; system vectors + jmp reset ; +20 reset entry + jmp nmi ; +23 nmi entry + jmp IRQStub ; +26 irq entry (135 hz) +;------------------------------------------------------------------------------- +reset: + ; setup the CPU and System-IRQ + + ; Initialize CPU + sei + cld + + ; Setup stack and memory mapping + ldx #$FF ; Stack top ($01FF) + txs + + ; Clear the BSS data + jsr zerobss + + ; Copy the .data segment to RAM + jsr copydata + + ; setup the stack + lda #<(__RAM_START__+__RAM_SIZE__) + sta sp + lda #>(__RAM_START__+__RAM_SIZE__) + sta sp + 1 + + ; Call module constructors + jsr initlib + + cli ; allow IRQ only after constructors have run + + ; Pass an empty command line + jsr push0 ; argc + jsr push0 ; argv + + ldy #4 ; Argument size + jsr _main ; call the users code + + ; Call module destructors. This is also the _exit entry. +_exit: + jsr donelib ; Run module destructors + + ; reset (start over) + jmp reset + + .export initmainargs +initmainargs: + rts + +;------------------------------------------------------------------------------- +nmi: + rts diff --git a/libsrc/gamate/ctype.s b/libsrc/gamate/ctype.s new file mode 100644 index 000000000..fa9a65c8b --- /dev/null +++ b/libsrc/gamate/ctype.s @@ -0,0 +1,161 @@ +; +; Stefan Haubenthal with minor changes from Ullrich von Bassewitz, 2003-05-02 +; +; Character specification table. +; + + .include "ctype.inc" + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. + + +__ctype: + .repeat 2 + .byte CT_CTRL ; 0/00 ___ctrl_@___ + .byte CT_CTRL ; 1/01 ___ctrl_A___ + .byte CT_CTRL ; 2/02 ___ctrl_B___ + .byte CT_CTRL ; 3/03 ___ctrl_C___ + .byte CT_CTRL ; 4/04 ___ctrl_D___ + .byte CT_CTRL ; 5/05 ___ctrl_E___ + .byte CT_CTRL ; 6/06 ___ctrl_F___ + .byte CT_CTRL ; 7/07 ___ctrl_G___ + .byte CT_CTRL ; 8/08 ___ctrl_H___ + .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB + ; 9/09 ___ctrl_I___ + .byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___ + .byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___ + .byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___ + .byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___ + .byte CT_CTRL ; 14/0e ___ctrl_N___ + .byte CT_CTRL ; 15/0f ___ctrl_O___ + .byte CT_CTRL ; 16/10 ___ctrl_P___ + .byte CT_CTRL ; 17/11 ___ctrl_Q___ + .byte CT_CTRL ; 18/12 ___ctrl_R___ + .byte CT_CTRL ; 19/13 ___ctrl_S___ + .byte CT_CTRL ; 20/14 ___ctrl_T___ + .byte CT_CTRL ; 21/15 ___ctrl_U___ + .byte CT_CTRL ; 22/16 ___ctrl_V___ + .byte CT_CTRL ; 23/17 ___ctrl_W___ + .byte CT_CTRL ; 24/18 ___ctrl_X___ + .byte CT_CTRL ; 25/19 ___ctrl_Y___ + .byte CT_CTRL ; 26/1a ___ctrl_Z___ + .byte CT_CTRL ; 27/1b ___ctrl_[___ + .byte CT_CTRL ; 28/1c ___ctrl_\___ + .byte CT_CTRL ; 29/1d ___ctrl_]___ + .byte CT_CTRL ; 30/1e ___ctrl_^___ + .byte CT_CTRL ; 31/1f ___ctrl_____ + .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___ + .byte CT_NONE ; 33/21 _____!_____ + .byte CT_NONE ; 34/22 _____"_____ + .byte CT_NONE ; 35/23 _____#_____ + .byte CT_NONE ; 36/24 _____$_____ + .byte CT_NONE ; 37/25 _____%_____ + .byte CT_NONE ; 38/26 _____&_____ + .byte CT_NONE ; 39/27 _____'_____ + .byte CT_NONE ; 40/28 _____(_____ + .byte CT_NONE ; 41/29 _____)_____ + .byte CT_NONE ; 42/2a _____*_____ + .byte CT_NONE ; 43/2b _____+_____ + .byte CT_NONE ; 44/2c _____,_____ + .byte CT_NONE ; 45/2d _____-_____ + .byte CT_NONE ; 46/2e _____._____ + .byte CT_NONE ; 47/2f _____/_____ + .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____ + .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____ + .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____ + .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____ + .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____ + .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____ + .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____ + .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____ + .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____ + .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____ + .byte CT_NONE ; 58/3a _____:_____ + .byte CT_NONE ; 59/3b _____;_____ + .byte CT_NONE ; 60/3c _____<_____ + .byte CT_NONE ; 61/3d _____=_____ + .byte CT_NONE ; 62/3e _____>_____ + .byte CT_NONE ; 63/3f _____?_____ + + .byte CT_NONE ; 64/40 _____@_____ + .byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____ + .byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____ + .byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____ + .byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____ + .byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____ + .byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____ + .byte CT_UPPER ; 71/47 _____G_____ + .byte CT_UPPER ; 72/48 _____H_____ + .byte CT_UPPER ; 73/49 _____I_____ + .byte CT_UPPER ; 74/4a _____J_____ + .byte CT_UPPER ; 75/4b _____K_____ + .byte CT_UPPER ; 76/4c _____L_____ + .byte CT_UPPER ; 77/4d _____M_____ + .byte CT_UPPER ; 78/4e _____N_____ + .byte CT_UPPER ; 79/4f _____O_____ + .byte CT_UPPER ; 80/50 _____P_____ + .byte CT_UPPER ; 81/51 _____Q_____ + .byte CT_UPPER ; 82/52 _____R_____ + .byte CT_UPPER ; 83/53 _____S_____ + .byte CT_UPPER ; 84/54 _____T_____ + .byte CT_UPPER ; 85/55 _____U_____ + .byte CT_UPPER ; 86/56 _____V_____ + .byte CT_UPPER ; 87/57 _____W_____ + .byte CT_UPPER ; 88/58 _____X_____ + .byte CT_UPPER ; 89/59 _____Y_____ + .byte CT_UPPER ; 90/5a _____Z_____ + .byte CT_NONE ; 91/5b _____[_____ + .byte CT_NONE ; 92/5c _____\_____ + .byte CT_NONE ; 93/5d _____]_____ + .byte CT_NONE ; 94/5e _____^_____ + .byte CT_NONE ; 95/5f _UNDERLINE_ + .byte CT_NONE ; 96/60 ___grave___ + .byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____ + .byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____ + .byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____ + .byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____ + .byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____ + .byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____ + .byte CT_LOWER ; 103/67 _____g_____ + .byte CT_LOWER ; 104/68 _____h_____ + .byte CT_LOWER ; 105/69 _____i_____ + .byte CT_LOWER ; 106/6a _____j_____ + .byte CT_LOWER ; 107/6b _____k_____ + .byte CT_LOWER ; 108/6c _____l_____ + .byte CT_LOWER ; 109/6d _____m_____ + .byte CT_LOWER ; 110/6e _____n_____ + .byte CT_LOWER ; 111/6f _____o_____ + .byte CT_LOWER ; 112/70 _____p_____ + .byte CT_LOWER ; 113/71 _____q_____ + .byte CT_LOWER ; 114/72 _____r_____ + .byte CT_LOWER ; 115/73 _____s_____ + .byte CT_LOWER ; 116/74 _____t_____ + .byte CT_LOWER ; 117/75 _____u_____ + .byte CT_LOWER ; 118/76 _____v_____ + .byte CT_LOWER ; 119/77 _____w_____ + .byte CT_LOWER ; 120/78 _____x_____ + .byte CT_LOWER ; 121/79 _____y_____ + .byte CT_LOWER ; 122/7a _____z_____ + .byte CT_NONE ; 123/7b _____{_____ + .byte CT_NONE ; 124/7c _____|_____ + .byte CT_NONE ; 125/7d _____}_____ + .byte CT_NONE ; 126/7e _____~_____ + .byte CT_OTHER_WS ; 127/7f ____DEL____ + .endrepeat + + diff --git a/libsrc/gamate/cvline.s b/libsrc/gamate/cvline.s new file mode 100644 index 000000000..b22890815 --- /dev/null +++ b/libsrc/gamate/cvline.s @@ -0,0 +1,32 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export _cvlinexy, _cvline + .import popa, _gotoxy, putchar, newline + .importzp tmp1 + + .include "gamate.inc" + +_cvlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_cvline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #CH_VLINE ; Vertical bar + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp1 + bne L1 +L9: rts + + + diff --git a/libsrc/gamate/extzp.inc b/libsrc/gamate/extzp.inc new file mode 100644 index 000000000..3e24d6e45 --- /dev/null +++ b/libsrc/gamate/extzp.inc @@ -0,0 +1,16 @@ +; +; extzp.inc for the Gamate +; +; Groepaz/Hitmen, 2015-11-19 +; +; Assembler include file that imports the runtime zero page locations used +; by the Gamate runtime, ready for usage in asm code. +; + + .global CURS_X: zp + .global CURS_Y: zp + .global CHARCOLOR: zp + .global RVS: zp + .global BGCOLOR: zp + .global tickcount: zp + diff --git a/libsrc/gamate/extzp.s b/libsrc/gamate/extzp.s new file mode 100644 index 000000000..d3189dcdd --- /dev/null +++ b/libsrc/gamate/extzp.s @@ -0,0 +1,16 @@ +; +; Groepaz/Hitmen, 2015-11-19 +; +; zeropage locations for exclusive use by the library +; + + .include "extzp.inc" + + .segment "EXTZP" : zeropage + +CURS_X: .res 1 +CURS_Y: .res 1 +CHARCOLOR: .res 1 +RVS: .res 1 +BGCOLOR: .res 1 +tickcount: .res 4 diff --git a/libsrc/gamate/gotoxy.s b/libsrc/gamate/gotoxy.s new file mode 100644 index 000000000..407da1f2f --- /dev/null +++ b/libsrc/gamate/gotoxy.s @@ -0,0 +1,22 @@ +; +; void gotoxy (unsigned char x, unsigned char y); +; + + .export _gotoxy + .import popa, plot + + .include "gamate.inc" + .include "extzp.inc" + +_gotoxy: + sta CURS_Y ; Set Y + jsr popa ; Get X + sta CURS_X ; Set X + jmp plot ; Set the cursor position + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio + diff --git a/libsrc/gamate/irq.s b/libsrc/gamate/irq.s new file mode 100644 index 000000000..4adbcb405 --- /dev/null +++ b/libsrc/gamate/irq.s @@ -0,0 +1,51 @@ +; +; IRQ handling (Gamate version) +; + + .export initirq, doneirq, IRQStub + + .import __INTERRUPTOR_COUNT__, callirq_y + + .include "gamate.inc" + .include "extzp.inc" + +; ------------------------------------------------------------------------ +.segment "INIT" + +; a constructor +; +initirq: + rts + +; ------------------------------------------------------------------------ +.code + +; a destructor +; +doneirq: + rts + +; ------------------------------------------------------------------------ +; 256*32 interrupts in about 1minute 60s = 136hz +; -> guess 16384 clock cycles = 135,28hz (might be audio signal 1/512?) + +IRQStub: + pha + tya + pha + + ldy #<(__INTERRUPTOR_COUNT__ * 2) + beq @L1 + + txa + pha + + jsr callirq_y + + pla + tax + +@L1: pla + tay + pla + rts diff --git a/libsrc/gamate/joy/gamate-stdjoy.s b/libsrc/gamate/joy/gamate-stdjoy.s new file mode 100644 index 000000000..8b18bae7a --- /dev/null +++ b/libsrc/gamate/joy/gamate-stdjoy.s @@ -0,0 +1,95 @@ + +; +; Standard joystick driver for the Gamate +; + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "gamate.inc" + + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _gamate_stdjoy_joy + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .addr $0000 + +; Button state masks (8 values) + + .byte $01 ; JOY_UP + .byte $02 ; JOY_DOWN + .byte $04 ; JOY_LEFT + .byte $08 ; JOY_RIGHT + .byte $10 ; JOY_FIRE_A + .byte $20 ; JOY_FIRE_B + .byte $80 ; JOY_SELECT + .byte $40 ; JOY_START + +; Jump table. + + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READJOY + .addr 0 ; IRQ entry unused + +; ------------------------------------------------------------------------ +; Constants + +JOY_COUNT = 1 ; Number of joysticks we support + + +.code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an JOY_ERR_xx code in a/x. +; + +INSTALL: + lda #<JOY_ERR_OK + ldx #>JOY_ERR_OK + +; rts ; Run into UNINSTALL instead + +; ------------------------------------------------------------------------ +; DEINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; +;unsigned char __fastcall__ joy_count (void); + +COUNT: + lda #<JOY_COUNT + ldx #>JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; +;unsigned char __fastcall__ joy_read (unsigned char joystick); + +READJOY: + lda JOY_DATA + ldx #0 + rts + diff --git a/libsrc/gamate/joy_stat_stddrv.s b/libsrc/gamate/joy_stat_stddrv.s new file mode 100644 index 000000000..75016450a --- /dev/null +++ b/libsrc/gamate/joy_stat_stddrv.s @@ -0,0 +1,14 @@ +; +; Address of the static standard joystick driver +; +; Oliver Schmidt, 2012-11-01 +; +; const void joy_static_stddrv[]; +; + + .export _joy_static_stddrv + .import _gamate_stdjoy_joy + +.rodata + +_joy_static_stddrv := _gamate_stdjoy_joy diff --git a/libsrc/gamate/joy_stddrv.s b/libsrc/gamate/joy_stddrv.s new file mode 100644 index 000000000..b830d8d86 --- /dev/null +++ b/libsrc/gamate/joy_stddrv.s @@ -0,0 +1,13 @@ +; +; Name of the standard joystick driver +; +; Oliver Schmidt, 2012-11-01 +; +; const char joy_stddrv[]; +; + + .export _joy_stddrv + +.rodata + +_joy_stddrv: .asciiz "gamate-stdjoy.joy" diff --git a/libsrc/gamate/kplot.s b/libsrc/gamate/kplot.s new file mode 100644 index 000000000..9091109b6 --- /dev/null +++ b/libsrc/gamate/kplot.s @@ -0,0 +1,32 @@ + + .export PLOT + + .include "gamate.inc" + .include "extzp.inc" + +PLOT: + bcs @getpos + + sty LCD_X + ;clc ; already cleared + lda _plotlo,x + sta LCD_Y + +@getpos: + ldx CURS_Y + ldy CURS_X + rts + + .export _plotlo + .rodata + +_plotlo: + .repeat screenrows,line + .byte <($0000+(line*$8)) + .endrepeat + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/gamate/libref.s b/libsrc/gamate/libref.s new file mode 100644 index 000000000..e4afa7eb1 --- /dev/null +++ b/libsrc/gamate/libref.s @@ -0,0 +1,8 @@ +; +; Oliver Schmidt, 2013-05-31 +; + + .export joy_libref + .import _exit + +joy_libref := _exit diff --git a/libsrc/gamate/revers.s b/libsrc/gamate/revers.s new file mode 100644 index 000000000..3b237e45b --- /dev/null +++ b/libsrc/gamate/revers.s @@ -0,0 +1,28 @@ + + .include "gamate.inc" + .include "extzp.inc" + + .export _revers + +.proc _revers + + ldx #$00 ; Assume revers off + tay ; Test onoff + beq L1 ; Jump if off + ldx #$ff ; Load on value + ldy #$00 ; Assume old value is zero +L1: lda RVS ; Load old value + stx RVS ; Set new value + beq L2 ; Jump if old value zero + iny ; Make old value = 1 +L2: ldx #$00 ; Load high byte of result + tya ; Load low byte, set CC + rts + +.endproc + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/gamate/ticktock.s b/libsrc/gamate/ticktock.s new file mode 100644 index 000000000..81f64dcf2 --- /dev/null +++ b/libsrc/gamate/ticktock.s @@ -0,0 +1,17 @@ + .interruptor ticktock, 24 + + .include "gamate.inc" + .include "extzp.inc" + +ticktock: + + ; Increment the system tick counter. + inc tickcount + bne @s1 + inc tickcount+1 + bne @s1 + inc tickcount+2 + bne @s1 + inc tickcount+3 +@s1: + rts diff --git a/libsrc/gamate/vga.inc b/libsrc/gamate/vga.inc new file mode 100644 index 000000000..f605258bb --- /dev/null +++ b/libsrc/gamate/vga.inc @@ -0,0 +1,228 @@ + +; VGA charset for the PC-Engine conio implementation + + .byte $00, $00, $00, $00, $00, $00, $00, $00 + ; 1 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %11111111 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + ; 2 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + ; 3 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %11111111 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + ; 4 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00011111 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + ; 5 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %11110000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + ; 6 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00011111 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + ; 7 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %11110000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + ; 8 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %11111111 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + ; 9 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %11111111 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + ; 10 (LF) + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + ; 11 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %11110000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + ; 12 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00011111 + .byte %00010000 + .byte %00010000 + .byte %00010000 + .byte %00010000 + + .byte $3F, $33, $3F, $30, $30, $70, $F0, $E0 + .byte $7F, $63, $7F, $63, $63, $67, $E6, $C0 + .byte $99, $5A, $3C, $E7, $E7, $3C, $5A, $99 + .byte $80, $E0, $F8, $FE, $F8, $E0, $80, $00 + .byte $02, $0E, $3E, $FE, $3E, $0E, $02, $00 + .byte $18, $3C, $7E, $18, $18, $7E, $3C, $18 + .byte $66, $66, $66, $66, $66, $00, $66, $00 + .byte $7F, $DB, $DB, $7B, $1B, $1B, $1B, $00 + .byte $3E, $63, $38, $6C, $6C, $38, $CC, $78 + .byte $00, $00, $00, $00, $7E, $7E, $7E, $00 + .byte $18, $3C, $7E, $18, $7E, $3C, $18, $FF + .byte $18, $3C, $7E, $18, $18, $18, $18, $00 + .byte $18, $18, $18, $18, $7E, $3C, $18, $00 + .byte $00, $18, $0C, $FE, $0C, $18, $00, $00 + .byte $00, $30, $60, $FE, $60, $30, $00, $00 + .byte $00, $00, $C0, $C0, $C0, $FE, $00, $00 + .byte $00, $24, $66, $FF, $66, $24, $00, $00 + .byte $00, $18, $3C, $7E, $FF, $FF, $00, $00 + .byte $00, $FF, $FF, $7E, $3C, $18, $00, $00 + .byte $00, $00, $00, $00, $00, $00, $00, $00 + .byte $30, $78, $78, $78, $30, $00, $30, $00 + .byte $6C, $6C, $6C, $00, $00, $00, $00, $00 + .byte $6C, $6C, $FE, $6C, $FE, $6C, $6C, $00 + .byte $30, $7C, $C0, $78, $0C, $F8, $30, $00 + .byte $00, $C6, $CC, $18, $30, $66, $C6, $00 + .byte $38, $6C, $38, $76, $DC, $CC, $76, $00 + .byte $60, $60, $C0, $00, $00, $00, $00, $00 + .byte $18, $30, $60, $60, $60, $30, $18, $00 + .byte $60, $30, $18, $18, $18, $30, $60, $00 + .byte $00, $66, $3C, $FF, $3C, $66, $00, $00 + .byte $00, $30, $30, $FC, $30, $30, $00, $00 + .byte $00, $00, $00, $00, $00, $30, $30, $60 + .byte $00, $00, $00, $FC, $00, $00, $00, $00 + .byte $00, $00, $00, $00, $00, $30, $30, $00 + .byte $06, $0C, $18, $30, $60, $C0, $80, $00 + .byte $7C, $C6, $CE, $DE, $F6, $E6, $7C, $00 + .byte $30, $70, $30, $30, $30, $30, $FC, $00 + .byte $78, $CC, $0C, $38, $60, $CC, $FC, $00 + .byte $78, $CC, $0C, $38, $0C, $CC, $78, $00 + .byte $1C, $3C, $6C, $CC, $FE, $0C, $1E, $00 + .byte $FC, $C0, $F8, $0C, $0C, $CC, $78, $00 + .byte $38, $60, $C0, $F8, $CC, $CC, $78, $00 + .byte $FC, $CC, $0C, $18, $30, $30, $30, $00 + .byte $78, $CC, $CC, $78, $CC, $CC, $78, $00 + .byte $78, $CC, $CC, $7C, $0C, $18, $70, $00 + .byte $00, $30, $30, $00, $00, $30, $30, $00 + .byte $00, $30, $30, $00, $00, $30, $30, $60 + .byte $18, $30, $60, $C0, $60, $30, $18, $00 + .byte $00, $00, $FC, $00, $00, $FC, $00, $00 + .byte $60, $30, $18, $0C, $18, $30, $60, $00 + .byte $78, $CC, $0C, $18, $30, $00, $30, $00 + .byte $7C, $C6, $DE, $DE, $DE, $C0, $78, $00 + .byte $30, $78, $CC, $CC, $FC, $CC, $CC, $00 + .byte $FC, $66, $66, $7C, $66, $66, $FC, $00 + .byte $3C, $66, $C0, $C0, $C0, $66, $3C, $00 + .byte $F8, $6C, $66, $66, $66, $6C, $F8, $00 + .byte $7E, $60, $60, $78, $60, $60, $7E, $00 + .byte $7E, $60, $60, $78, $60, $60, $60, $00 + .byte $3C, $66, $C0, $C0, $CE, $66, $3E, $00 + .byte $CC, $CC, $CC, $FC, $CC, $CC, $CC, $00 + .byte $78, $30, $30, $30, $30, $30, $78, $00 + .byte $1E, $0C, $0C, $0C, $CC, $CC, $78, $00 + .byte $E6, $66, $6C, $78, $6C, $66, $E6, $00 + .byte $60, $60, $60, $60, $60, $60, $7E, $00 + .byte $C6, $EE, $FE, $FE, $D6, $C6, $C6, $00 + .byte $C6, $E6, $F6, $DE, $CE, $C6, $C6, $00 + .byte $38, $6C, $C6, $C6, $C6, $6C, $38, $00 + .byte $FC, $66, $66, $7C, $60, $60, $F0, $00 + .byte $78, $CC, $CC, $CC, $DC, $78, $1C, $00 + .byte $FC, $66, $66, $7C, $6C, $66, $E6, $00 + .byte $78, $CC, $E0, $70, $1C, $CC, $78, $00 + .byte $FC, $30, $30, $30, $30, $30, $30, $00 + .byte $CC, $CC, $CC, $CC, $CC, $CC, $FC, $00 + .byte $CC, $CC, $CC, $CC, $CC, $78, $30, $00 + .byte $C6, $C6, $C6, $D6, $FE, $EE, $C6, $00 + .byte $C6, $C6, $6C, $38, $38, $6C, $C6, $00 + .byte $CC, $CC, $CC, $78, $30, $30, $78, $00 + .byte $FE, $06, $0C, $18, $30, $60, $FE, $00 + .byte $78, $60, $60, $60, $60, $60, $78, $00 + .byte $C0, $60, $30, $18, $0C, $06, $02, $00 + .byte $78, $18, $18, $18, $18, $18, $78, $00 + .byte $10, $38, $6C, $C6, $00, $00, $00, $00 + .byte $00, $00, $00, $00, $00, $00, $00, $FF + .byte $30, $30, $18, $00, $00, $00, $00, $00 + .byte $00, $00, $78, $0C, $7C, $CC, $76, $00 + .byte $E0, $60, $60, $7C, $66, $66, $DC, $00 + .byte $00, $00, $78, $CC, $C0, $CC, $78, $00 + .byte $1C, $0C, $0C, $7C, $CC, $CC, $76, $00 + .byte $00, $00, $78, $CC, $FC, $C0, $78, $00 + .byte $38, $6C, $60, $F0, $60, $60, $F0, $00 + .byte $00, $00, $76, $CC, $CC, $7C, $0C, $F8 + .byte $E0, $60, $6C, $76, $66, $66, $E6, $00 + .byte $30, $00, $70, $30, $30, $30, $78, $00 + .byte $0C, $00, $0C, $0C, $0C, $CC, $CC, $78 + .byte $E0, $60, $66, $6C, $78, $6C, $E6, $00 + .byte $70, $30, $30, $30, $30, $30, $78, $00 + .byte $00, $00, $CC, $FE, $FE, $D6, $C6, $00 + .byte $00, $00, $F8, $CC, $CC, $CC, $CC, $00 + .byte $00, $00, $78, $CC, $CC, $CC, $78, $00 + .byte $00, $00, $DC, $66, $66, $7C, $60, $F0 + .byte $00, $00, $76, $CC, $CC, $7C, $0C, $1E + .byte $00, $00, $DC, $76, $66, $60, $F0, $00 + .byte $00, $00, $7C, $C0, $78, $0C, $F8, $00 + .byte $10, $30, $7C, $30, $30, $34, $18, $00 + .byte $00, $00, $CC, $CC, $CC, $CC, $76, $00 + .byte $00, $00, $CC, $CC, $CC, $78, $30, $00 + .byte $00, $00, $C6, $D6, $FE, $FE, $6C, $00 + .byte $00, $00, $C6, $6C, $38, $6C, $C6, $00 + .byte $00, $00, $CC, $CC, $CC, $7C, $0C, $F8 + .byte $00, $00, $FC, $98, $30, $64, $FC, $00 + .byte $1C, $30, $30, $E0, $30, $30, $1C, $00 + .byte $18, $18, $18, $00, $18, $18, $18, $00 + .byte $E0, $30, $30, $1C, $30, $30, $E0, $00 + .byte $76, $DC, $00, $00, $00, $00, $00, $00 + .byte $00, $10, $38, $6C, $C6, $C6, $FE, $00 diff --git a/libsrc/gamate/waitvblank.s b/libsrc/gamate/waitvblank.s new file mode 100644 index 000000000..66686c08a --- /dev/null +++ b/libsrc/gamate/waitvblank.s @@ -0,0 +1,20 @@ +; +; void waitvblank (void); +; + + .include "gamate.inc" + .include "extzp.inc" + + .forceimport ticktock + .export _waitvblank + +; FIXME: is this actually correct? + +.proc _waitvblank + + lda tickcount +@lp: cmp tickcount + beq @lp + rts + +.endproc diff --git a/libsrc/gamate/wherex.s b/libsrc/gamate/wherex.s new file mode 100644 index 000000000..94d9ae741 --- /dev/null +++ b/libsrc/gamate/wherex.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherex (void); +; + + .export _wherex + + .include "gamate.inc" + .include "extzp.inc" + +.proc _wherex + + lda CURS_X + ldx #$00 + rts + +.endproc + + diff --git a/libsrc/gamate/wherey.s b/libsrc/gamate/wherey.s new file mode 100644 index 000000000..70e2f54fe --- /dev/null +++ b/libsrc/gamate/wherey.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherey (void); +; + + .export _wherey + + .include "gamate.inc" + .include "extzp.inc" + +.proc _wherey + + lda CURS_Y + ldx #$00 + rts + +.endproc + + diff --git a/src/common/target.c b/src/common/target.c index ebd05cbf1..e89010123 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -205,7 +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_65C02, BINFMT_BINARY, CTNone }, + { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, }; /* Target system */ diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index 3a8048632..2ae6b46b3 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -14,6 +14,14 @@ #include <string.h> #include <stdlib.h> +#if defined(__GAMATE__) +#define NUMCHARS 128 +#define NUMCOLS 4 +#else +#define NUMCHARS 256 +#define NUMCOLS 16 +#endif + static char grid[5][5] = { { CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER }, { CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, @@ -29,8 +37,10 @@ void main(void) clrscr(); screensize(&xsize, &ysize); - cputs("cc65 conio test\n\rInput: [ ]"); - + cputs("cc65 conio test\n\r"); +#if !defined(__NES__) && !defined(__PCE__) && !defined(__GAMATE__) + cputs("Input: [ ]"); +#endif cputsxy(0, 2, "Colors:" ); tcol = textcolor(0); /* remember original textcolor */ bgcol = bgcolor(0); /* remember original background color */ @@ -38,14 +48,14 @@ void main(void) bgcolor(bgcol);bordercolor(bcol); for (i = 0; i < 3; ++i) { gotoxy(i,3 + i); - for (j = 0; j < 16; ++j) { + for (j = 0; j < NUMCOLS; ++j) { textcolor(j); cputc('X'); } } textcolor(tcol); - cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize ); + cprintf("\n\n\r Screensize: %dx%d", xsize, ysize ); chlinexy(0,6,xsize); cvlinexy(0,6,3); @@ -63,13 +73,13 @@ void main(void) } } - gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); + gotoxy(0,ysize - 2 - ((NUMCHARS + xsize) / xsize)); revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } revers(0); - for (i = 0; i < 256; ++i) { + for (i = 0; i < NUMCHARS; ++i) { if ((i != '\n') && (i != '\r')) { cputc(i); } else { @@ -89,13 +99,14 @@ void main(void) for(;;) { gotoxy(8, 2); - j = n & 1; + j = n >> 4 & 1; revers(j); cputc(j ? 'R' : ' '); revers(j ^ 1); - cputs(" revers"); + cputs(" rvs"); revers(0); +#if !defined(__NES__) && !defined(__PCE__) && !defined(__GAMATE__) gotoxy(8 + inpos,1); i = cgetc(); if ((i >= '0') && (i<='9')) { @@ -120,6 +131,10 @@ void main(void) cputc(i); inpos = (inpos + 1) & 7; } +#endif +#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) + waitvblank(); +#endif ++n; } diff --git a/testcode/lib/gamate/Makefile b/testcode/lib/gamate/Makefile index 943f6c195..3fe95b693 100644 --- a/testcode/lib/gamate/Makefile +++ b/testcode/lib/gamate/Makefile @@ -1,21 +1,20 @@ -all: audiotest.bin lcdtest.bin +all: audiotest.bin lcdtest.bin ctest.bin audiotest.bin: audiotest.s -# ../../../bin/ca65 -t gamate -o audiotest.o audiotest.s -# ../../../bin/ld65 -t gamate -o audiotest.bin audiotest.o - ../../../bin/cl65 -t gamate -o audiotest.bin audiotest.s - + ../../../bin/cl65 -l audiotest.lst -t gamate -o audiotest.bin audiotest.s lcdtest.bin: lcdtest.s -# ../../../bin/ca65 -t gamate -o lcdtest.o lcdtest.s -# ../../../bin/ld65 -t gamate -o lcdtest.bin lcdtest.o - ../../../bin/cl65 -l bla.lst -t gamate -o lcdtest.bin lcdtest.s + ../../../bin/cl65 -l lcdtest.lst -t gamate -o lcdtest.bin lcdtest.s +ctest.bin: ctest.c + ../../../bin/cl65 -l ctest.lst -t gamate -o ctest.bin ctest.c test1: lcdtest.bin - cd /home/groepaz/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart /home/groepaz/Desktop/cc65/github/cc65/testcode/lib/gamate/lcdtest.bin + cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/lcdtest.bin test2: audiotest.bin - cd /home/groepaz/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart /home/groepaz/Desktop/cc65/github/cc65/testcode/lib/gamate/audiotest.bin + cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/audiotest.bin +testc: ctest.bin + cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/ctest.bin clean: - rm -f lcdtest.o audiotest.o - rm -f lcdtest.bin audiotest.bin + rm -f lcdtest.o audiotest.o ctest.o + rm -f lcdtest.bin audiotest.bin ctest.bin diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index a5b2143ce..0375592f3 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -1,8 +1,10 @@ - .export reset, irq, nmi ; FIXME +; .export reset, irq, nmi ; FIXME + .export _main -.include "gamate.inc" - .zeropage + .include "gamate.inc" + +.zeropage addr: .word 0 psa: .word 0 @@ -16,7 +18,7 @@ cursor: .byte 0 controlslast: .byte 0 controlsedge: .byte 0 - .data +.data temp_x: .byte 0 temp_y: .byte 0 temp_a: .byte 0 @@ -27,405 +29,414 @@ psy: .byte 0 xpos: .byte 0 ypos: .byte 0 - .code +.code chars: .incbin "cga2.chr" - + hex2asc: .byte "0123456789abcdef" +;------------------------------------------------------------------------------- + .export IRQStub + .proc nmi - inc nmi_count - rts + inc nmi_count + rts .endproc -.proc irq - inc irq_count - rts +.proc IRQStub + 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 +.proc _main + lda #>AUDIO_BASE + sta writeaddr+1 + sta readaddr+1 + lda #<AUDIO_BASE + sta writeaddr + sta readaddr - 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 + 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 - jsr printy + 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 #1 - sta nmi_enable + jsr printy + + lda #1 + sta ZP_NMI_ENABLE loop: - lda irq_count + lda irq_count loop1: - cmp irq_count - beq loop1 - lda irq_count - and #7 - bne loop1 + cmp irq_count + beq loop1 + lda irq_count + and #7 + bne loop1 - lda #lcd_mode_y_increment - sta lcd_mode + lda #LCD_MODE_INC_Y + sta LCD_MODE - ldx #3 - ldy #32 - lda irq_count - jsr printhex + ldx #3 + ldy #32 + lda irq_count + jsr printhex - lda cursor - ldy #0 - cmp #20 - bcc firstline - sec - sbc #20 - ldy #24 + lda cursor + ldy #0 + cmp #20 + bcc firstline + sec + 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 - lda irq_count - and #8 - bne nocursor - lda cursor - ldy #0 - cmp #20 - bcc firstline2 - sec - sbc #20 - ldy #24 + 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 + sta LCD_X + sty LCD_Y + lda #'x' + jsr printsign nocursor: - lda #lcd_mode_y_increment - 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 - pla - tay - iny - cpy #10 - bne 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 + 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 + ldx #0 + ldy #32 + lda nmi_count + jsr printhex - rts + rts .endproc +;------------------------------------------------------------------------------- + .proc inputs - lda controlslast - eor controls - and controlslast - eor #$ff - sta controlsedge - and #up - bne notup + 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 - clc - adc #$10 - sta readaddr,y - jmp 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 + 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 + and #JOY_DATA_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 + lda readaddr,y + sec + sbc #1 + sta readaddr,y notdown:lda controlsedge - and #left - bne notleft - lda cursor - beq notleft - dec cursor + and #JOY_DATA_LEFT + bne notleft + lda cursor + beq notleft + dec cursor notleft:lda controlsedge - and #right - bne notright - lda cursor - cmp #40 - beq notright - inc cursor + and #JOY_DATA_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 + 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 #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 + 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 #button_a - bne notbuttona - ldy #0 - ldy #0 + and #JOY_DATA_FIRE_A + bne notbuttona + ldy #0 + ldy #0 writea:lda editbuffer1,y - sta (writeaddr),y - iny - cpy #8 - bne writea + sta (writeaddr),y + iny + cpy #8 + bne writea writeb:lda editbuffer2-8,y - sta (writeaddr),y - iny - cpy #16 - bne writeb + sta (writeaddr),y + iny + cpy #16 + bne writeb notbuttona:lda controlsedge - and #button_b - bne notbuttonb - ldy #0 + and #JOY_DATA_FIRE_B + bne notbuttonb + ldy #0 reada:lda (readaddr),y - sta editbuffer1,y - iny - cpy #8 - bne reada + sta editbuffer1,y + iny + cpy #8 + bne reada readb:lda (readaddr),y - sta editbuffer2-8,y - iny - cpy #16 - bne readb + sta editbuffer2-8,y + iny + cpy #16 + bne readb notbuttonb: - lda controls - sta controlslast - rts + 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 - clc - adc #1 - sta psa - lda psa+1 - adc #0 - sta psa+1 - jmp 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 + 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 - clc - adc #1 - sta psa - lda psa+1 - adc #0 - sta psa+1 - jmp 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 + 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 + 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 + 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 + lda (addr),y + sta LCD_DATA + iny + dex + bne printsign1 + ldx temp_x + ldy temp_y + rts .endproc diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c new file mode 100644 index 000000000..a953e0e63 --- /dev/null +++ b/testcode/lib/gamate/ctest.c @@ -0,0 +1,52 @@ + +#include <gamate.h> +#include <time.h> +#include <conio.h> + +unsigned char y = 0; +unsigned char x; +unsigned short n; + +int main(int argc, char *argv[]) +{ + clrscr(); + gotoxy(0,0);cputs("abcdABCD"); + + textcolor(0);gotoxy(0,5);cputs("abcdABCD 0"); + textcolor(1);gotoxy(0,6);cputs("abcdABCD 1"); + textcolor(2);gotoxy(0,7);cputs("abcdABCD 2"); + textcolor(3);gotoxy(0,8);cputs("abcdABCD 3"); + + while(1) { + textcolor(COLOR_BLACK); + + n = clock(); + + gotoxy(0,2);cprintf("%04x %02x %02x", n, x, y); + + switch((*((unsigned char*)JOY_DATA))) { + case 0xff ^ JOY_DATA_UP: + ++y; + break; + case 0xff ^ JOY_DATA_DOWN: + --y; + break; + case 0xff ^ JOY_DATA_LEFT: + ++x; + break; + case 0xff ^ JOY_DATA_RIGHT: + --x; + break; + case 0xff ^ JOY_DATA_FIRE_A: + break; + } + + (*((unsigned char*)LCD_XPOS)) = x; + (*((unsigned char*)LCD_YPOS)) = y; + + waitvblank(); + + } + + return 0; +} diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index b4798c677..617f89959 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -1,14 +1,12 @@ - .export reset, irq, nmi ; FIXME - - + .export _main .include "gamate.inc" - .zeropage +.zeropage addr: .word 0 psa: .word 0 - .data +.data temp_x: .byte 0 temp_y: .byte 0 temp_a: .byte 0 @@ -21,363 +19,381 @@ counted: .word 0 xpos: .byte 0 ypos: .byte 0 - .code +.code chars: -.incbin "cga2.chr" - -hex2asc: .byte "0123456789abcdef" -format: .byte "IrqNmiCountXposYpos", 0 -xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0 -ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 + .incbin "cga2.chr" -.proc nmi - inc nmi_count - rts +hex2asc: .byte "0123456789abcdef" +format: .byte "IrqNmiCountXposYpos", 0 +xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0 +ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 + +;------------------------------------------------------------------------------- + +.proc nmi + + inc nmi_count + rts .endproc + .export IRQStub -.proc irq - inc irq_count - lda count - sta counted - lda count+1 - sta counted+1 - lda #0 - sta count - sta count+1 - rts +.proc IRQStub + + 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 +.proc _main - lda #lcd_x_pos_plane2_flag - sta lcd_x - lda #<xdesc - ldx #>xdesc - ldy #128 - jsr printstring + lda #0 + sta LCD_XPOS + sta LCD_YPOS + cli + lda #LCD_MODE_INC_Y + sta LCD_MODE - lda #0 - sta lcd_x - lda #<ydesc - ldx #>ydesc - ldy #0 - sty lcd_y - jsr printstringy + lda #0 + sta LCD_X + lda #<xdesc + ldx #>xdesc + ldy #0 + jsr printstring -; 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 #LCD_XPOS_PLANE2 + sta LCD_X + lda #<xdesc + ldx #>xdesc + ldy #128 + jsr printstring - lda #<format - ldx #>format - ldy #8 - jsr printstring + lda #0 + sta LCD_X + lda #<ydesc + ldx #>ydesc + ldy #0 + sty LCD_Y + jsr printstringy - 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 #$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 #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 #<format + ldx #>format + ldy #8 + jsr printstring - 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 #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 nmi_enable + lda #1 + sta ZP_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 + 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 + 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 #0 + ldy #16 + lda irq_count + jsr printhex - ldx #3 - ldy #16 - lda nmi_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 #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 + 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 + 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 - clc - adc #1 - sta psa - lda psa+1 - adc #0 - sta psa+1 - jmp 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 + 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 - clc - adc #1 - sta psa - lda psa+1 - adc #0 - sta psa+1 - jmp 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 + 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 + 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 + 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 + lda (addr),y + sta LCD_DATA + iny + dex + bne printsign1 + + ldx temp_x + ldy temp_y + rts .endproc diff --git a/util/gamate/gamate-fixcart.c b/util/gamate/gamate-fixcart.c new file mode 100644 index 000000000..a99483844 --- /dev/null +++ b/util/gamate/gamate-fixcart.c @@ -0,0 +1,25 @@ + +#include <stdlib.h> +#include <stdio.h> + +unsigned char buffer[512 * 1024]; +unsigned len; +FILE *in, *out; +int n, i; + +int main(int argc, char *argv[]) { + if (argc < 3) { + exit(-1); + } + in = fopen(argv[1], "rb"); + out = fopen(argv[2], "wb"); + len = fread(buffer, 1, 512 * 1024, in); + n = 0; for (i = 0x1000; i < 0x2000; i++) { + n += buffer[i]; + } + buffer[0] = n & 0xff; + buffer[1] = (n >> 8) & 0xff; + fwrite(buffer, 1, len, out); + fclose(in); + fclose(out); +} From 1893e24da978e0fa4fd8338a1060ed0272d25b22 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 01:24:01 +0100 Subject: [PATCH 04/16] updated --- include/gamate.h | 2 +- libsrc/gamate/conio.s | 1 - testcode/lib/gamate/audiotest.s | 10 +++++----- testcode/lib/gamate/ctest.c | 4 +++- testcode/lib/gamate/lcdtest.s | 10 ++++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/gamate.h b/include/gamate.h index f89f5204e..7d5c02a9a 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (w) 2015 Groepaz/Hitmen (groepaz@gmx.net) */ +/* (w) 2015 Groepaz/Hitmen (groepaz@gmx.net) */ /* based on technical reference by PeT (mess@utanet.at) */ /* */ /* This software is provided 'as-is', without any expressed or implied */ diff --git a/libsrc/gamate/conio.s b/libsrc/gamate/conio.s index 4840b372c..a43eeb1a3 100644 --- a/libsrc/gamate/conio.s +++ b/libsrc/gamate/conio.s @@ -10,7 +10,6 @@ .segment "INIT" initconio: - ; FIXME lda #0 sta LCD_XPOS sta LCD_YPOS diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index 0375592f3..2fa38a500 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -1,11 +1,11 @@ -; .export reset, irq, nmi ; FIXME +; original audiotest.s by PeT (mess@utanet.at) + .export _main - .include "gamate.inc" -.zeropage -addr: .word 0 + .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 @@ -32,7 +32,7 @@ ypos: .byte 0 .code chars: -.incbin "cga2.chr" + .incbin "cga2.chr" hex2asc: .byte "0123456789abcdef" diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c index a953e0e63..da81bf240 100644 --- a/testcode/lib/gamate/ctest.c +++ b/testcode/lib/gamate/ctest.c @@ -10,7 +10,7 @@ unsigned short n; int main(int argc, char *argv[]) { clrscr(); - gotoxy(0,0);cputs("abcdABCD"); + gotoxy(0,0);cputs("Gamate C-Test"); textcolor(0);gotoxy(0,5);cputs("abcdABCD 0"); textcolor(1);gotoxy(0,6);cputs("abcdABCD 1"); @@ -40,6 +40,8 @@ int main(int argc, char *argv[]) case 0xff ^ JOY_DATA_FIRE_A: break; } + if (y == 0xff) y = 0xc7; + if (y == 0xc8) y = 0; (*((unsigned char*)LCD_XPOS)) = x; (*((unsigned char*)LCD_YPOS)) = y; diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index 617f89959..41242a982 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -1,12 +1,14 @@ +; original lcdtest.s by PeT (mess@utanet.at) + .export _main -.include "gamate.inc" + .include "gamate.inc" -.zeropage -addr: .word 0 + .zeropage +addr: .word 0 psa: .word 0 -.data + .data temp_x: .byte 0 temp_y: .byte 0 temp_a: .byte 0 From c636675521a4804d3f93b6ffb0261753ff01ee45 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 16:01:36 +0100 Subject: [PATCH 05/16] moved cart header into seperate file, moved nmi stub into several file, tweaked linker config --- cfg/gamate.cfg | 9 +++++---- libsrc/gamate/crt0.s | 27 +++------------------------ libsrc/gamate/header.s | 16 ++++++++++++++++ libsrc/gamate/nmi.s | 7 +++++++ testcode/lib/gamate/audiotest.s | 16 +++++++--------- testcode/lib/gamate/ctest.c | 14 ++++++-------- testcode/lib/gamate/lcdtest.s | 10 +++++----- util/gamate/gamate-fixcart.c | 4 ++++ 8 files changed, 53 insertions(+), 50 deletions(-) create mode 100644 libsrc/gamate/header.s create mode 100644 libsrc/gamate/nmi.s diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index 577dfeb1d..d7c87b455 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -8,23 +8,24 @@ SYMBOLS { MEMORY { # 0000-03ff is RAM # FIXME: what zp range can we actually use? - ZP: start = $0080, size = $80; + ZP: start = $0020, size = $e0; CPUSTACK: start = $0100, size =$100; - RAM: start = $0200, size = $180, define = yes; + RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes; + CARTHEADER: file = %O, define = yes, start = %S, size = $0029; # 6000-e000 can be (Cartridge) ROM # WARNING: fill value must be $00 else it will no more work #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; # for images that have code >$6fff we must calculate the checksum! - ROM: start = $6000, size = $8000, fill = yes, fillval = $00, file = %O, define = yes; + ROM: start = $6000 + $29, size = $8000 - $29, fill = yes, fillval = $00, file = %O, define = yes; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; EXTZP: load = ZP, type = zp, define = yes, optional = yes; APPZP: load = ZP, type = zp, define = yes, optional = yes; - STARTUP: load = ROM, type = ro, define=yes; + STARTUP: load = CARTHEADER, type = ro, define=yes; INIT: load = ROM, type = ro, define = yes, optional = yes; CODE: load = ROM, type = ro, define=yes; RODATA: load = ROM, type = ro, define=yes; diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index b54d8ade1..5df5ad38c 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -1,33 +1,16 @@ - .export __STARTUP__ : absolute = 1 ; Mark as startup + .export Start, _exit .import initlib, donelib, callmain .import push0, _main, zerobss, copydata - .import IRQStub - ; Linker generated symbols .import __RAM_START__, __RAM_SIZE__ - .import __ROM_START__, __ROM_SIZE__ - .import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ - .import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ - .import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ .include "zeropage.inc" .include "gamate.inc" - .segment "STARTUP" - - .word 0 ; +00 checksum from 7000-7fff (simple 8bit adds) - .byte 1, 0, 1 ; +02 flags - .byte "COPYRIGHT BIT CORPORATION", 0, $ff ; +05 copyright - ; system vectors - jmp reset ; +20 reset entry - jmp nmi ; +23 nmi entry - jmp IRQStub ; +26 irq entry (135 hz) - -;------------------------------------------------------------------------------- -reset: +Start: ; setup the CPU and System-IRQ ; Initialize CPU @@ -67,12 +50,8 @@ _exit: jsr donelib ; Run module destructors ; reset (start over) - jmp reset + jmp Start .export initmainargs initmainargs: rts - -;------------------------------------------------------------------------------- -nmi: - rts diff --git a/libsrc/gamate/header.s b/libsrc/gamate/header.s new file mode 100644 index 000000000..da15a51eb --- /dev/null +++ b/libsrc/gamate/header.s @@ -0,0 +1,16 @@ + ; The following symbol is used by linker config to force the module + ; to get included into the output file + .export __STARTUP__: absolute = 1 + + .import Start, IRQStub, NMIStub + + + .segment "STARTUP" + + .word 0 ; +00 checksum from 7000-7fff (simple 8bit adds) + .byte 1, 0, 1 ; +02 flags + .byte "COPYRIGHT BIT CORPORATION", 0, $ff ; +05 copyright + ; system vectors + jmp Start ; +20 reset entry + jmp NMIStub ; +23 nmi entry + jmp IRQStub ; +26 irq entry (135 hz) diff --git a/libsrc/gamate/nmi.s b/libsrc/gamate/nmi.s new file mode 100644 index 000000000..918431340 --- /dev/null +++ b/libsrc/gamate/nmi.s @@ -0,0 +1,7 @@ +; +; NMI handling (Gamate version) +; + .export NMIStub + +NMIStub: + rts \ No newline at end of file diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index 2fa38a500..1b5d22767 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -1,7 +1,6 @@ ; original audiotest.s by PeT (mess@utanet.at) - .export _main .include "gamate.inc" .zeropage @@ -29,17 +28,15 @@ psy: .byte 0 xpos: .byte 0 ypos: .byte 0 -.code + .code -chars: - .incbin "cga2.chr" - -hex2asc: .byte "0123456789abcdef" +chars: .incbin "cga2.chr" +hex2asc: .byte "0123456789abcdef" ;------------------------------------------------------------------------------- - .export IRQStub + .export IRQStub, NMIStub -.proc nmi +.proc NMIStub inc nmi_count rts .endproc @@ -50,8 +47,9 @@ hex2asc: .byte "0123456789abcdef" .endproc ;------------------------------------------------------------------------------- + .export Start -.proc _main +.proc Start lda #>AUDIO_BASE sta writeaddr+1 sta readaddr+1 diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c index da81bf240..dfebd9bef 100644 --- a/testcode/lib/gamate/ctest.c +++ b/testcode/lib/gamate/ctest.c @@ -4,7 +4,7 @@ #include <conio.h> unsigned char y = 0; -unsigned char x; +unsigned char x = 0; unsigned short n; int main(int argc, char *argv[]) @@ -22,14 +22,14 @@ int main(int argc, char *argv[]) n = clock(); - gotoxy(0,2);cprintf("%04x %02x %02x", n, x, y); + gotoxy(0,2);cprintf("%04x %02x %02x %02x", n, x, y, *((unsigned char*)JOY_DATA)); switch((*((unsigned char*)JOY_DATA))) { case 0xff ^ JOY_DATA_UP: - ++y; + ++y; if (y == 0xc8) y = 0; break; case 0xff ^ JOY_DATA_DOWN: - --y; + --y; if (y == 0xff) y = 0xc7; break; case 0xff ^ JOY_DATA_LEFT: ++x; @@ -40,14 +40,12 @@ int main(int argc, char *argv[]) case 0xff ^ JOY_DATA_FIRE_A: break; } - if (y == 0xff) y = 0xc7; - if (y == 0xc8) y = 0; + + waitvblank(); (*((unsigned char*)LCD_XPOS)) = x; (*((unsigned char*)LCD_YPOS)) = y; - waitvblank(); - } return 0; diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index 41242a982..3ac8f968b 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -1,7 +1,6 @@ ; original lcdtest.s by PeT (mess@utanet.at) - .export _main .include "gamate.inc" .zeropage @@ -32,15 +31,15 @@ xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0 ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 ;------------------------------------------------------------------------------- + .export IRQStub, NMIStub -.proc nmi + +.proc NMIStub inc nmi_count rts .endproc - .export IRQStub - .proc IRQStub inc irq_count @@ -55,8 +54,9 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 .endproc ;------------------------------------------------------------------------------- + .export Start -.proc _main +.proc Start lda #0 sta LCD_XPOS diff --git a/util/gamate/gamate-fixcart.c b/util/gamate/gamate-fixcart.c index a99483844..e38832461 100644 --- a/util/gamate/gamate-fixcart.c +++ b/util/gamate/gamate-fixcart.c @@ -13,6 +13,9 @@ int main(int argc, char *argv[]) { } in = fopen(argv[1], "rb"); out = fopen(argv[2], "wb"); + if (!in || !out) { + exit(-1); + } len = fread(buffer, 1, 512 * 1024, in); n = 0; for (i = 0x1000; i < 0x2000; i++) { n += buffer[i]; @@ -22,4 +25,5 @@ int main(int argc, char *argv[]) { fwrite(buffer, 1, len, out); fclose(in); fclose(out); + return (0); } From b39a8b7a618c049ec1c885d7af53fbee44494c18 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 20:04:10 +0100 Subject: [PATCH 06/16] more cleanup --- asminc/gamate.inc | 22 +- cfg/gamate.cfg | 3 +- include/gamate.h | 23 +- include/time.h | 4 +- libsrc/gamate/clrscr.s | 2 +- libsrc/gamate/cputc.s | 12 - libsrc/gamate/crt0.s | 8 +- libsrc/gamate/extzp.inc | 2 +- libsrc/gamate/extzp.s | 2 +- libsrc/gamate/irq.s | 13 +- libsrc/gamate/nmi.s | 16 +- testcode/lib/gamate/audiotest.s | 632 ++++++++++++++++---------------- testcode/lib/gamate/lcdtest.s | 537 ++++++++++++++------------- 13 files changed, 669 insertions(+), 607 deletions(-) diff --git a/asminc/gamate.inc b/asminc/gamate.inc index 167c9b1e1..4e7fee2b0 100644 --- a/asminc/gamate.inc +++ b/asminc/gamate.inc @@ -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 diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index d7c87b455..90ced1ea5 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -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; diff --git a/include/gamate.h b/include/gamate.h index 7d5c02a9a..7b1c04a81 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -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 @@ -132,6 +133,26 @@ #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 diff --git a/include/time.h b/include/time.h index 33bcbb569..22e24a56e 100644 --- a/include/time.h +++ b/include/time.h @@ -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 */ diff --git a/libsrc/gamate/clrscr.s b/libsrc/gamate/clrscr.s index c96fc4eda..31a7a1874 100644 --- a/libsrc/gamate/clrscr.s +++ b/libsrc/gamate/clrscr.s @@ -6,10 +6,10 @@ .export _clrscr _clrscr: ldy #$0 + tya rowloop: sty LCD_X - lda #0 sta LCD_Y ldx #$0 diff --git a/libsrc/gamate/cputc.s b/libsrc/gamate/cputc.s index 0ebd659b2..7c95ba8fc 100644 --- a/libsrc/gamate/cputc.s +++ b/libsrc/gamate/cputc.s @@ -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 diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index 5df5ad38c..ead45b7ea 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -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 diff --git a/libsrc/gamate/extzp.inc b/libsrc/gamate/extzp.inc index 3e24d6e45..b6f08bcad 100644 --- a/libsrc/gamate/extzp.inc +++ b/libsrc/gamate/extzp.inc @@ -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. diff --git a/libsrc/gamate/extzp.s b/libsrc/gamate/extzp.s index d3189dcdd..41f559233 100644 --- a/libsrc/gamate/extzp.s +++ b/libsrc/gamate/extzp.s @@ -1,5 +1,5 @@ ; -; Groepaz/Hitmen, 2015-11-19 +; Groepaz/Hitmen, 2015-11-27 ; ; zeropage locations for exclusive use by the library ; diff --git a/libsrc/gamate/irq.s b/libsrc/gamate/irq.s index 4adbcb405..862307f58 100644 --- a/libsrc/gamate/irq.s +++ b/libsrc/gamate/irq.s @@ -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 diff --git a/libsrc/gamate/nmi.s b/libsrc/gamate/nmi.s index 918431340..61db62416 100644 --- a/libsrc/gamate/nmi.s +++ b/libsrc/gamate/nmi.s @@ -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 diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index 1b5d22767..6eab34b22 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -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 +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 -.word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 ; get out of sensitiv area + .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 -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 + .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 + sei + lda #0 + sta ZP_IRQ_CTRL - 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 #>AUDIO_BASE + sta writeaddr+1 + sta readaddr+1 + lda #<AUDIO_BASE + sta writeaddr + sta readaddr - lda #0 - sta LCD_XPOS - sta LCD_YPOS - sta irq_count - sta cursor - lda #1 - sta nmi_count + 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 + cmp irq_count + beq loop1 + lda irq_count + and #7 + bne loop1 - lda #LCD_MODE_INC_Y - sta LCD_MODE + lda #LCD_MODE_INC_Y + sta LCD_MODE - ldx #3 - ldy #32 - lda irq_count - jsr printhex + ldx #3 + ldy #32 + lda irq_count + jsr printhex - - lda cursor - ldy #0 - cmp #20 - bcc firstline + 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 controlslast + eor JOY_DATA + and controlslast + eor #$ff + sta controlsedge + and #JOY_DATA_UP + bne notup - lda cursor + 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 - diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index 3ac8f968b..3a8d72226 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -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 +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 + .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 -.code + .rodata -chars: - .incbin "cga2.chr" +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 #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 #LCD_XPOS_PLANE2 + 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 #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 #(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 #<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 #24/8 + sta LCD_X + lda #24 + sta LCD_Y + lda #'X' + 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 #$80 + sta LCD_MODE + lda #32/8 + sta LCD_X + lda #32 + sta LCD_Y + lda #'Y' + 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 #$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 #1 - sta ZP_NMI_ENABLE + lda #$80 + sta LCD_MODE + lda #(LCD_XPOS_PLANE2|(56/8)) + sta LCD_X + lda #56 + sta LCD_Y + lda #'y' + jsr printsign -loop: lda count + 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 #0 + ldy #16 + lda irq_count + jsr printhex - ldx #3 - ldy #16 - lda nmi_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 #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 #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 From 4d1dc551381bedd55152ef7a655a55914f8ccac1 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 21:15:10 +0100 Subject: [PATCH 07/16] dont use that silly buffer --- util/gamate/gamate-fixcart.c | 38 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/util/gamate/gamate-fixcart.c b/util/gamate/gamate-fixcart.c index e38832461..ba09ac083 100644 --- a/util/gamate/gamate-fixcart.c +++ b/util/gamate/gamate-fixcart.c @@ -2,28 +2,36 @@ #include <stdlib.h> #include <stdio.h> -unsigned char buffer[512 * 1024]; -unsigned len; -FILE *in, *out; -int n, i; +FILE *in; +unsigned int n, i, c; + +void usage(char *arg) +{ + printf("usage: %s [file]\n", arg); + exit(-1); +} int main(int argc, char *argv[]) { - if (argc < 3) { + if (argc < 2) { + usage(argv[0]); exit(-1); } - in = fopen(argv[1], "rb"); - out = fopen(argv[2], "wb"); - if (!in || !out) { + + if (!(in = fopen(argv[1], "r+b"))) { + fprintf(stderr, "couldnt open: '%s'\n", argv[1]); exit(-1); } - len = fread(buffer, 1, 512 * 1024, in); - n = 0; for (i = 0x1000; i < 0x2000; i++) { - n += buffer[i]; + /* read 0x1000 bytes from 0x7000-0x7fff (offset 0x1000) */ + fseek(in, 0x1000, SEEK_SET); + n = 0; for (i = 0; i < 0x1000; i++) { + c = fgetc(in); + n += c; } - buffer[0] = n & 0xff; - buffer[1] = (n >> 8) & 0xff; - fwrite(buffer, 1, len, out); + /* write checksum to header */ + fseek(in, 0, SEEK_SET); + fputc(n & 0xff, in); + fputc((n >> 8) & 0xff, in); + fclose(in); - fclose(out); return (0); } From aff2d95cb9ca285a298c78da8e325e01eb331cb5 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 21:15:28 +0100 Subject: [PATCH 08/16] fix docs --- doc/gamate.sgml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/gamate.sgml b/doc/gamate.sgml index 227672b1b..0029c02cc 100644 --- a/doc/gamate.sgml +++ b/doc/gamate.sgml @@ -5,7 +5,7 @@ <title>Gamate System specific information for cc65 <author> <url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen"> -<date>2015-11-14 +<date>2015-11-29 <abstract> An overview over the Gamate runtime system as it is implemented for the @@ -36,6 +36,9 @@ 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. +Note: the first two bytes of the header contain a checksum that must be inserted +by an external program. Such an utility is provided in util/gamate/gamate-fixcart.c + <sect>Platform specific header files<p> Programs containing Gamate specific code may use the <tt/gamate.h/ header file. @@ -92,7 +95,8 @@ No serial drivers are currently available for the Gamate. <sect>Limitations<p> <itemize> -<item>interruptor support in crt0 (and cfg) is missing +<item>When using the C-compiler, keep in mind that only 0x300 bytes RAM in total +can be used for variables and the runtime stack. </itemize> <sect1>Disk I/O<p> @@ -118,7 +122,8 @@ following functions (and a few others): <sect>Other hints<p> <itemize> -<item>a good emulator to use for Gamate is "MESS/MAME" (<url url="http://www.mess.org/">) +<item>The Gamate is emulated by MESS (<url url="http://www.mess.org/">), +run like this: <tt>mess gamate -debug -window -skip_gameinfo -cart test.bin</tt> </itemize> some resources on the Gamate: From 3bc1375c90597cf5124f996efae72ad9fcf815d5 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Sun, 29 Nov 2015 22:00:59 +0100 Subject: [PATCH 09/16] fix typo --- doc/gamate.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/gamate.sgml b/doc/gamate.sgml index 0029c02cc..14b1a27e9 100644 --- a/doc/gamate.sgml +++ b/doc/gamate.sgml @@ -95,7 +95,7 @@ No serial drivers are currently available for the Gamate. <sect>Limitations<p> <itemize> -<item>When using the C-compiler, keep in mind that only 0x300 bytes RAM in total +<item>When using the C-compiler, keep in mind that only 0x200 bytes RAM in total can be used for variables and the runtime stack. </itemize> From 7496e669be53edca7fa25e56d0ccd99321841e9f Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 30 Nov 2015 18:44:04 +0100 Subject: [PATCH 10/16] fixed stuff according to Olivers review --- include/gamate.h | 40 ++++++++++++++++++++-------------------- testcode/lib/conio.c | 2 ++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/gamate.h b/include/gamate.h index 7b1c04a81..b7c2fef7a 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -158,25 +158,25 @@ #define COLOR_BLACK 0x03 #define COLOR_WHITE 0x00 -#define CH_HLINE 1 -#define CH_VLINE 2 -#define CH_CROSS 3 -#define CH_ULCORNER 4 -#define CH_URCORNER 5 -#define CH_LLCORNER 6 -#define CH_LRCORNER 7 -#define CH_TTEE 8 -#define CH_BTEE 9 +#define CH_HLINE 1 +#define CH_VLINE 2 +#define CH_CROSS 3 +#define CH_ULCORNER 4 +#define CH_URCORNER 5 +#define CH_LLCORNER 6 +#define CH_LRCORNER 7 +#define CH_TTEE 8 +#define CH_BTEE 9 -#define CH_RTEE 11 -#define CH_LTEE 12 +#define CH_RTEE 11 +#define CH_LTEE 12 -#define CH_ENTER 13 -#define CH_PI 18 +#define CH_ENTER 13 +#define CH_PI 18 -#define TV_NTSC 0 -#define TV_PAL 1 -#define TV_OTHER 2 +#define TV_NTSC 0 +#define TV_PAL 1 +#define TV_OTHER 2 /* No support for dynamically loadable drivers */ #define DYN_DRV 0 @@ -184,15 +184,15 @@ /* The addresses of the static drivers */ extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ -#define JOY_FIRE_B 5 -#define JOY_START 6 -#define JOY_SELECT 7 +#define JOY_FIRE_B 5 +#define JOY_START 6 +#define JOY_SELECT 7 void waitvblank (void); /* Wait for the vertical blanking */ /* NOTE: all Gamate are "NTSC" */ -#define get_tv() TV_NTSC +#define get_tv() TV_NTSC /* Return the video mode the machine is using. */ /* End of gamate.h */ diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index 2ae6b46b3..7a5e6f822 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -15,6 +15,7 @@ #include <stdlib.h> #if defined(__GAMATE__) +/* there is not enough screen space to show all 256 characters at the bottom */ #define NUMCHARS 128 #define NUMCOLS 4 #else @@ -132,6 +133,7 @@ void main(void) inpos = (inpos + 1) & 7; } #endif +/* not all targets have waitvblank() */ #if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) waitvblank(); #endif From a95c95a5d3d16ab85773a32349850ae668e5ea61 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 30 Nov 2015 18:49:52 +0100 Subject: [PATCH 11/16] added black line :) --- libsrc/gamate/cputc.s | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsrc/gamate/cputc.s b/libsrc/gamate/cputc.s index 7c95ba8fc..c7b11c8c9 100644 --- a/libsrc/gamate/cputc.s +++ b/libsrc/gamate/cputc.s @@ -72,7 +72,8 @@ putchar: lda #0 sta ptr3+1 - ; * 8 + + ; char index * 8 asl ptr3 rol ptr3+1 asl ptr3 @@ -80,6 +81,7 @@ putchar: asl ptr3 rol ptr3+1 + ; plus fontdata base address lda ptr3 clc adc #<(fontdata-$f8) From b851be1b2357794e223825c84dbec1b4d60cee04 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 30 Nov 2015 19:16:28 +0100 Subject: [PATCH 12/16] naive music test --- testcode/lib/gamate/Makefile | 7 +- testcode/lib/gamate/audiotest.s | 1 + testcode/lib/gamate/nachtm.c | 1147 +++++++++++++++++++++++++++++++ 3 files changed, 1154 insertions(+), 1 deletion(-) create mode 100644 testcode/lib/gamate/nachtm.c diff --git a/testcode/lib/gamate/Makefile b/testcode/lib/gamate/Makefile index 3fe95b693..2cf98d189 100644 --- a/testcode/lib/gamate/Makefile +++ b/testcode/lib/gamate/Makefile @@ -7,6 +7,9 @@ lcdtest.bin: lcdtest.s ../../../bin/cl65 -l lcdtest.lst -t gamate -o lcdtest.bin lcdtest.s ctest.bin: ctest.c ../../../bin/cl65 -l ctest.lst -t gamate -o ctest.bin ctest.c +nachtm.bin: nachtm.c + ../../../bin/cl65 -Os -l nachtm.lst -t gamate -o nachtm.bin nachtm.c + gamate-fixcart nachtm.bin test1: lcdtest.bin cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/lcdtest.bin @@ -14,7 +17,9 @@ test2: audiotest.bin cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/audiotest.bin testc: ctest.bin cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/ctest.bin +testn: nachtm.bin + cd ~/Desktop/mame/winmess/ && wine mess.exe gamate -window -skip_gameinfo -cart ~/Desktop/cc65/github/cc65/testcode/lib/gamate/nachtm.bin clean: rm -f lcdtest.o audiotest.o ctest.o - rm -f lcdtest.bin audiotest.bin ctest.bin + rm -f lcdtest.bin audiotest.bin ctest.bin nachtm.bin diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index 6eab34b22..f40199994 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -275,6 +275,7 @@ notstart: lda controlsedge and #JOY_DATA_SELECT bne notselect + lda editbuffer1 sta AUDIO_BASE lda editbuffer1+1 diff --git a/testcode/lib/gamate/nachtm.c b/testcode/lib/gamate/nachtm.c new file mode 100644 index 000000000..780e95693 --- /dev/null +++ b/testcode/lib/gamate/nachtm.c @@ -0,0 +1,1147 @@ +/* +** "Eine kleine Nachtmusik" by Wolfgang Amadeus Mozart, KV 525 +** +** First version in 1987 by +** Joachim von Bassewitz (joachim@von-bassewitz.de) and +** Ullrich von Bassewitz (ullrich@von-bassewitz.de). +** +** C conversion in 1998 by +** Ullrich von Bassewitz (ullrich@von-bassewitz.de) +** +*/ + + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <conio.h> +#include <gamate.h> + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +/* Tables with voice data. +** +** Bit Description +** ------------------------------------------- +** 15 Pause bit. +** 12-14 Octave +** 8-11 Tone (index into frequency table) +** 7 Unused. Was thought as a control bit in the original version to +** change SID parameters, but this was never implemented. +** 0-6 Length of the tone in ticks. +** +*/ + +const unsigned Voice1 [] = { + 0x5708,0x8004,0x5204,0x5708,0x8004,0x5204,0x5704,0x5204,0x5704,0x5B04, + 0x6208,0x8008,0x6008,0x8004,0x5904,0x6008,0x8004,0x5904,0x6004,0x5904, + 0x5604,0x5904,0x5208,0x8008,0x5704,0x8004,0x570C,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5904,0x5704,0x5704,0x5604,0x560C,0x5901,0x5901,0x5901,0x5901, + 0x6004,0x5604,0x5901,0x5901,0x5901,0x5901,0x5704,0x570C,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5904,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604,0x560C, + 0x5901,0x5901,0x5901,0x5901,0x6004,0x5604,0x5704,0x5704,0x5601,0x5601, + 0x5601,0x5601,0x5401,0x5401,0x5602,0x5704,0x5704,0x5901,0x5901,0x5901, + 0x5901,0x5701,0x5701,0x5902,0x5B04,0x5B04,0x6001,0x6001,0x6001,0x6001, + 0x5B01,0x5B01,0x6001,0x6001,0x6208,0x8008,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5410,0x5008,0x5008,0x4B08,0x4B08,0x4908,0x4908,0x4701, + 0x4701,0x4701,0x4701,0x4604,0x4404,0x4604,0x4704,0x8004,0x4904,0x8004, + 0x4B04,0x800C,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5410,0x5201, + 0x5201,0x5201,0x5201,0x5004,0x5004,0x5004,0x5001,0x5001,0x5001,0x5001, + 0x4B04,0x4B04,0x4B04,0x4B01,0x4B01,0x4B01,0x4B01,0x4904,0x4904,0x4904, + 0x4701,0x4701,0x4701,0x4701,0x4601,0x4601,0x4601,0x4601,0x4401,0x4401, + 0x4401,0x4401,0x4604,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701, + 0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4704, + 0x4701,0x4701,0x4601,0x4701,0x4901,0x4901,0x4901,0x4901,0x4604,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B04,0x4B01,0x4B01,0x4901,0x4B01, + 0x5001,0x5001,0x5001,0x5001,0x4904,0x5210,0x5408,0x5608,0x5708,0x5908, + 0x5B08,0x6108,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x5904,0x6101,0x6101,0x6101,0x6101,0x6101, + 0x6101,0x5902,0x6101,0x6101,0x6101,0x6101,0x6101,0x6101,0x5902,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x5904,0x6101,0x6101,0x6101,0x6101,0x6101,0x6101,0x5902,0x6101, + 0x6101,0x6101,0x6101,0x6101,0x6101,0x5902,0x6204,0x6208,0x6208,0x6208, + 0x6201,0x6201,0x6201,0x6201,0x6204,0x6208,0x6208,0x6208,0x6204,0x6104, + 0x5904,0x6204,0x5904,0x6004,0x5904,0x6204,0x5904,0x6104,0x4904,0x4904, + 0x4904,0x4908,0x8008,0x590A,0x5702,0x5602,0x5402,0x5204,0x8004,0x5B04, + 0x8004,0x5704,0x8004,0x5404,0x8004,0x5B04,0x800C,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5201, + 0x5201,0x5101,0x5101,0x4B04,0x8004,0x5704,0x8004,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5408,0x8008,0x5901,0x5901,0x5901,0x5901,0x5901, + 0x5901,0x5901,0x5901,0x5901,0x5901,0x5701,0x5701,0x5601,0x5601,0x5401, + 0x5401,0x5204,0x8004,0x5B04,0x8004,0x5704,0x8004,0x5404,0x8004,0x5908, + 0x8004,0x5704,0x6104,0x6204,0x8004,0x5B04,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5904,0x8004,0x5104,0x5208,0x8004,0x5904,0x6201,0x6201,0x6201,0x6201, + 0x6101,0x6101,0x6101,0x6101,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5B01, + 0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904,0x5904,0x5904,0x5904,0x5904, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904,0x6204,0x6104,0x5B04, + 0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904,0x5904,0x5904, + 0x5904,0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8008,0x5B0A,0x5901, + 0x5901,0x5701,0x5701,0x5601,0x5601,0x5708,0x8008,0x590A,0x5701,0x5701, + 0x5601,0x5601,0x5401,0x5401,0x5608,0x8008,0x5B01,0x5B01,0x5B01,0x5B01, + 0x6101,0x6101,0x6201,0x6201,0x6104,0x5B04,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5904,0x5604,0x5904,0x5901,0x5901,0x5901,0x5901,0x5704,0x5604,0x5404, + 0x5208,0x8004,0x5904,0x6201,0x6201,0x6201,0x6201,0x6101,0x6101,0x6101, + 0x6101,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5904,0x8004,0x5904,0x5904,0x5904,0x5904,0x5904,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5904,0x8004,0x5904,0x6201,0x6201,0x6201,0x6201,0x6101,0x6101, + 0x6101,0x6101,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5904,0x8004,0x5904,0x5904,0x5904,0x5904,0x5904,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5904,0x8008,0x5B0A,0x5901,0x5901,0x5701,0x5701,0x5601, + 0x5601,0x5708,0x8008,0x590A,0x5701,0x5701,0x5601,0x5601,0x5401,0x5401, + 0x5608,0x8008,0x5B01,0x5B01,0x5B01,0x5B01,0x6101,0x6101,0x6201,0x6201, + 0x6104,0x5B04,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5604,0x5904,0x5901, + 0x5901,0x5901,0x5901,0x5704,0x5604,0x5404,0x5204,0x4904,0x4B04,0x5104, + 0x5204,0x5204,0x5401,0x5401,0x5401,0x5401,0x5201,0x5201,0x5401,0x5401, + 0x5604,0x5104,0x5204,0x5404,0x5604,0x5604,0x5701,0x5701,0x5701,0x5701, + 0x5601,0x5601,0x5701,0x5701,0x5904,0x5904,0x5A04,0x5802,0x5A02,0x5B08, + 0x8008,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x5404,0x5201,0x5201,0x5201,0x5201,0x5101,0x5101, + 0x5101,0x5101,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901,0x5901,0x5901, + 0x6204,0x8004,0x6604,0x8004,0x6204,0x800C,0x5708,0x8004,0x5204,0x5708, + 0x8004,0x5204,0x5704,0x5204,0x5704,0x5B04,0x6208,0x8008,0x6008,0x8004, + 0x5904,0x6008,0x8004,0x5904,0x6004,0x5904,0x5604,0x5904,0x5208,0x8008, + 0x5704,0x8004,0x570C,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5704,0x5704, + 0x5604,0x560C,0x5901,0x5901,0x5901,0x5901,0x6004,0x5604,0x5901,0x5901, + 0x5901,0x5901,0x5704,0x570C,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5704, + 0x5701,0x5701,0x5701,0x5701,0x5604,0x560C,0x5901,0x5901,0x5901,0x5901, + 0x6004,0x5604,0x5704,0x5704,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401, + 0x5602,0x5704,0x5704,0x5901,0x5901,0x5901,0x5901,0x5701,0x5701,0x5902, + 0x5B04,0x5B04,0x6001,0x6001,0x6001,0x6001,0x5B01,0x5B01,0x6001,0x6001, + 0x6208,0x8008,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5410,0x5008, + 0x5008,0x4B08,0x4B08,0x4908,0x4908,0x4701,0x4701,0x4701,0x4701,0x4604, + 0x4404,0x4604,0x4704,0x8004,0x4904,0x8004,0x4B04,0x800C,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5410,0x5201,0x5201,0x5201,0x5201,0x5004, + 0x5004,0x5004,0x5001,0x5001,0x5001,0x5001,0x4B04,0x4B04,0x4B04,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4904,0x4904,0x4904,0x4701,0x4701,0x4701,0x4701, + 0x4601,0x4601,0x4601,0x4601,0x4401,0x4401,0x4401,0x4401,0x4604,0x4701, + 0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701,0x4701, + 0x4701,0x4701,0x4701,0x4701,0x4701,0x4704,0x4701,0x4701,0x4601,0x4701, + 0x4901,0x4901,0x4901,0x4901,0x4604,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B04,0x4B01,0x4B01,0x4901,0x4B01,0x5001,0x5001,0x5001,0x5001, + 0x4904,0x5210,0x5408,0x5608,0x5708,0x5908,0x5B08,0x6108,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x5904,0x6101,0x6101,0x6101,0x6101,0x6101,0x6101,0x5902,0x6101,0x6101, + 0x6101,0x6101,0x6101,0x6101,0x5902,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x5904,0x6101,0x6101, + 0x6101,0x6101,0x6101,0x6101,0x5902,0x6101,0x6101,0x6101,0x6101,0x6101, + 0x6101,0x5902,0x6204,0x6208,0x6208,0x6208,0x6201,0x6201,0x6201,0x6201, + 0x6204,0x6208,0x6208,0x6208,0x6204,0x6104,0x5904,0x6204,0x5904,0x6004, + 0x5904,0x6204,0x5904,0x6104,0x4904,0x4904,0x4904,0x4908,0x8008,0x590A, + 0x5702,0x5602,0x5402,0x5204,0x8004,0x5B04,0x8004,0x5704,0x8004,0x5404, + 0x8004,0x5B04,0x800C,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5401,0x5401,0x5201,0x5201,0x5101,0x5101,0x4B04, + 0x8004,0x5704,0x8004,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5408, + 0x8008,0x5901,0x5901,0x5901,0x5901,0x5901,0x5901,0x5901,0x5901,0x5901, + 0x5901,0x5701,0x5701,0x5601,0x5601,0x5401,0x5401,0x5204,0x8004,0x5B04, + 0x8004,0x5704,0x8004,0x5404,0x8004,0x5908,0x8004,0x5704,0x6104,0x6204, + 0x8004,0x5B04,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5104,0x5208, + 0x8004,0x5904,0x6201,0x6201,0x6201,0x6201,0x6101,0x6101,0x6101,0x6101, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904, + 0x8004,0x5904,0x5904,0x5904,0x5904,0x5904,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5904,0x8004,0x5904,0x6204,0x6104,0x5B04,0x5904,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5904,0x8004,0x5904,0x5904,0x5904,0x5904,0x5904,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5904,0x8008,0x5B0A,0x5901,0x5901,0x5701,0x5701,0x5601, + 0x5601,0x5708,0x8008,0x590A,0x5701,0x5701,0x5601,0x5601,0x5401,0x5401, + 0x5608,0x8008,0x5B01,0x5B01,0x5B01,0x5B01,0x6101,0x6101,0x6201,0x6201, + 0x6104,0x5B04,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5604,0x5904,0x5901, + 0x5901,0x5901,0x5901,0x5704,0x5604,0x5404,0x5208,0x8004,0x5904,0x6201, + 0x6201,0x6201,0x6201,0x6101,0x6101,0x6101,0x6101,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904,0x5904, + 0x5904,0x5904,0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904, + 0x6201,0x6201,0x6201,0x6201,0x6101,0x6101,0x6101,0x6101,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904, + 0x5904,0x5904,0x5904,0x5904,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8008, + 0x5B0A,0x5901,0x5901,0x5701,0x5701,0x5601,0x5601,0x5708,0x8008,0x590A, + 0x5701,0x5701,0x5601,0x5601,0x5401,0x5401,0x5608,0x8008,0x5B01,0x5B01, + 0x5B01,0x5B01,0x6101,0x6101,0x6201,0x6201,0x6104,0x5B04,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5904,0x5604,0x5904,0x5901,0x5901,0x5901,0x5901,0x5704, + 0x5604,0x5404,0x5204,0x4904,0x4B04,0x5104,0x5204,0x5204,0x5401,0x5401, + 0x5401,0x5401,0x5201,0x5201,0x5401,0x5401,0x5604,0x5104,0x5204,0x5404, + 0x5604,0x5604,0x5701,0x5701,0x5701,0x5701,0x5601,0x5601,0x5701,0x5701, + 0x5904,0x5904,0x5A04,0x5802,0x5A02,0x5B08,0x8008,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x5404, + 0x5201,0x5201,0x5201,0x5201,0x5101,0x5101,0x5101,0x5101,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5901,0x5901,0x5901,0x5901,0x6204,0x8004,0x6604,0x8004, + 0x6204,0x800C,0x5208,0x8004,0x4904,0x5208,0x8004,0x4904,0x5204,0x4904, + 0x5204,0x5604,0x5908,0x8008,0x5908,0x8004,0x5604,0x5908,0x8004,0x5604, + 0x5904,0x5604,0x5304,0x5604,0x4B08,0x8014,0x5704,0x6001,0x6001,0x6001, + 0x6001,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901,0x5901,0x5901,0x5704, + 0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704,0x5704,0x5704,0x5704, + 0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704,0x6001,0x6001, + 0x6001,0x6001,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901,0x5901,0x5901, + 0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704,0x5704,0x5704, + 0x5704,0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704,0x6001, + 0x6001,0x6001,0x6001,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901,0x5901, + 0x5901,0x5704,0x5901,0x5901,0x5901,0x5901,0x5804,0x8004,0x5804,0x5804, + 0x5804,0x5804,0x5804,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x8004,0x5904, + 0x6001,0x6001,0x6001,0x6001,0x5A01,0x5A01,0x5A01,0x5A01,0x5901,0x5901, + 0x5901,0x5901,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604,0x8004,0x5604, + 0x5604,0x5604,0x5604,0x5604,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004, + 0x5304,0x5704,0x5504,0x5304,0x5204,0x5201,0x5201,0x5201,0x5201,0x5104, + 0x8004,0x5104,0x5104,0x5104,0x5104,0x5104,0x5401,0x5401,0x5401,0x5401, + 0x5204,0x8004,0x4201,0x4201,0x4201,0x4201,0x4401,0x4401,0x4401,0x4401, + 0x4601,0x4601,0x4601,0x4601,0x4701,0x4701,0x4701,0x4701,0x4901,0x4901, + 0x4901,0x4901,0x5001,0x5001,0x5001,0x5001,0x4A04,0x8004,0x4601,0x4601, + 0x4601,0x4601,0x4701,0x4701,0x4701,0x4701,0x4901,0x4901,0x4901,0x4901, + 0x4A01,0x4A01,0x4A01,0x4A01,0x5101,0x5101,0x5101,0x5101,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x8004,0x5201,0x5201,0x5201,0x5201,0x5401,0x5401, + 0x5401,0x5401,0x5601,0x5601,0x5601,0x5601,0x5701,0x5701,0x5701,0x5701, + 0x5901,0x5901,0x5901,0x5901,0x5A01,0x5A01,0x5A01,0x5A01,0x5A01,0x5A01, + 0x5A01,0x5A01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01, + 0x6001,0x6001,0x6001,0x6001,0x6001,0x6001,0x6001,0x6001,0x6108,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6210,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5602,0x5708,0x8004,0x5204, + 0x5708,0x8004,0x5204,0x5704,0x5204,0x5704,0x5B04,0x6208,0x8008,0x6008, + 0x8004,0x5904,0x6008,0x8004,0x5904,0x6004,0x5904,0x5604,0x5904,0x5208, + 0x8008,0x5704,0x8004,0x570C,0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5704, + 0x5701,0x5701,0x5701,0x5701,0x5604,0x560C,0x5901,0x5901,0x5901,0x5901, + 0x6004,0x5604,0x5901,0x5901,0x5901,0x5901,0x5704,0x570C,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5904,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604,0x560C, + 0x5901,0x5901,0x5901,0x5901,0x6004,0x5604,0x5704,0x5704,0x5601,0x5601, + 0x5601,0x5601,0x5401,0x5401,0x5602,0x5704,0x5704,0x5901,0x5901,0x5901, + 0x5901,0x5701,0x5701,0x5902,0x5B04,0x5B04,0x6001,0x6001,0x6001,0x6001, + 0x5B01,0x5B01,0x6001,0x6001,0x6208,0x8008,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5410,0x5008,0x5008,0x4B08,0x4B08,0x4908,0x4908,0x4701, + 0x4701,0x4701,0x4701,0x4604,0x4404,0x4604,0x4704,0x8004,0x4904,0x8004, + 0x4B04,0x800C,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5410,0x5201, + 0x5201,0x5201,0x5201,0x5004,0x5004,0x5004,0x5001,0x5001,0x5001,0x5001, + 0x4B04,0x4B04,0x4B04,0x4B01,0x4B01,0x4B01,0x4B01,0x4904,0x4904,0x4904, + 0x4701,0x4701,0x4701,0x4701,0x4604,0x4404,0x4604,0x4714,0x4701,0x4701, + 0x4601,0x4701,0x4901,0x4901,0x4901,0x4901,0x4604,0x4B14,0x4B01,0x4B01, + 0x4901,0x4B01,0x5001,0x5001,0x5001,0x5001,0x4904,0x5210,0x5408,0x5608, + 0x5708,0x5908,0x5B08,0x5108,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x5904,0x6101,0x6101,0x6101, + 0x6101,0x6101,0x6101,0x5902,0x5101,0x5101,0x5101,0x5101,0x5101,0x5101, + 0x5902,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x5904,0x6101,0x6101,0x6101,0x6101,0x6101,0x6101, + 0x5902,0x5101,0x5101,0x5101,0x5101,0x5101,0x5101,0x5902,0x6204,0x5904, + 0x6104,0x5904,0x6204,0x5904,0x6104,0x5904,0x6204,0x4204,0x4204,0x4204, + 0x4208,0x8008,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5001,0x5001,0x4B01,0x4B01,0x4901,0x4901,0x4704,0x8004, + 0x5404,0x8004,0x5004,0x8004,0x4904,0x8004,0x5204,0x800C,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901, + 0x5701,0x5701,0x5601,0x5601,0x5404,0x8004,0x6004,0x8004,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5908,0x8008,0x8004,0x6204,0x6204,0x6204, + 0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6201,0x6201, + 0x6201,0x6201,0x6001,0x6001,0x6001,0x6001,0x5901,0x5901,0x5901,0x5901, + 0x5604,0x5601,0x5601,0x5601,0x5601,0x5704,0x8004,0x5404,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x8004,0x4604,0x4708,0x8004,0x5204,0x5701,0x5701, + 0x5701,0x5701,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5401,0x5401, + 0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5204,0x5204, + 0x5204,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5704, + 0x5604,0x5404,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204, + 0x5204,0x5204,0x5204,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8008, + 0x540A,0x5201,0x5201,0x5001,0x5001,0x4B01,0x4B01,0x5008,0x8008,0x520A, + 0x5001,0x5001,0x4B01,0x4B01,0x4901,0x4901,0x4B08,0x8008,0x5401,0x5401, + 0x5401,0x5401,0x5601,0x5601,0x5701,0x5701,0x5604,0x5404,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x4B04,0x5204,0x5201,0x5201,0x5201,0x5201,0x5004, + 0x4B04,0x4904,0x4708,0x8004,0x5204,0x5701,0x5701,0x5701,0x5701,0x5601, + 0x5601,0x5601,0x5601,0x5401,0x5401,0x5401,0x5401,0x5204,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x8004,0x5204,0x5204,0x5204,0x5204,0x5204,0x5401, + 0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5701,0x5701,0x5701,0x5701, + 0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5401,0x5401,0x5204,0x5401, + 0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5204,0x5204,0x5204,0x5204, + 0x5401,0x5401,0x5401,0x5401,0x5204,0x8008,0x640A,0x6201,0x6201,0x6001, + 0x6001,0x5B01,0x5B01,0x6008,0x8008,0x620A,0x6001,0x6001,0x5B01,0x5B01, + 0x5901,0x5901,0x5B08,0x8008,0x5401,0x5401,0x5401,0x5401,0x5601,0x5601, + 0x5701,0x5701,0x5604,0x5404,0x5204,0x5704,0x5B04,0x6204,0x6201,0x6201, + 0x6201,0x6201,0x6004,0x5B04,0x5904,0x5704,0x4204,0x4404,0x4604,0x4704, + 0x4704,0x4901,0x4901,0x4901,0x4901,0x4701,0x4701,0x4901,0x4901,0x4B04, + 0x4604,0x4704,0x4904,0x4B04,0x4B04,0x5001,0x5001,0x5001,0x5001,0x4B01, + 0x4B01,0x5001,0x5001,0x5204,0x5204,0x5301,0x5301,0x5301,0x5301,0x5101, + 0x5101,0x5301,0x5301,0x5408,0x8008,0x440C,0x4904,0x4704,0x4604,0x4404, + 0x4204,0x5201,0x5201,0x5201,0x5201,0x5101,0x5101,0x5101,0x5101,0x5001, + 0x5001,0x5001,0x5001,0x4B01,0x4B01,0x4B01,0x4B01,0x5201,0x5201,0x5201, + 0x5201,0x5101,0x5101,0x5101,0x5101,0x5001,0x5001,0x5001,0x5001,0x4B04, + 0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4904,0x4701,0x4701,0x4701,0x4701,0x4601,0x4601,0x4601, + 0x4601,0x4401,0x4401,0x4401,0x4401,0x4204,0x5201,0x5201,0x5201,0x5201, + 0x5401,0x5401,0x5401,0x5401,0x5601,0x5601,0x5601,0x5601,0x5701,0x5701, + 0x5701,0x5701,0x5201,0x5201,0x5201,0x5201,0x5401,0x5401,0x5401,0x5401, + 0x5601,0x5601,0x5601,0x5601,0x5704,0x5908,0x8008,0x6208,0x8008,0x5708, + 0x8004,0x5204,0x4B04,0x4704,0x4B04,0x5204,0x5704,0x5204,0x5704,0x5B04, + 0x6208,0x5608,0x5708,0x8004,0x5204,0x4B04,0x4704,0x4B04,0x5204,0x5704, + 0x5204,0x5704,0x5B04,0x6208,0x5608,0x5708,0x8008,0x5708,0x8008,0x5708, + 0x4706,0x4702,0x4708,0x8008,0x5208,0x8004,0x4904,0x5208,0x8004,0x4904, + 0x5204,0x4904,0x5204,0x5604,0x5908,0x8008,0x5908,0x8004,0x5604,0x5908, + 0x8004,0x5604,0x5904,0x5604,0x5304,0x5604,0x4B08,0x8014,0x5704,0x6001, + 0x6001,0x6001,0x6001,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901,0x5901, + 0x5901,0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704,0x5704, + 0x5704,0x5704,0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704, + 0x6001,0x6001,0x6001,0x6001,0x5B01,0x5B01,0x5B01,0x5B01,0x5901,0x5901, + 0x5901,0x5901,0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004,0x5704, + 0x5704,0x5704,0x5704,0x5704,0x5901,0x5901,0x5901,0x5901,0x5704,0x8004, + 0x5704,0x6001,0x6001,0x6001,0x6001,0x5B01,0x5B01,0x5B01,0x5B01,0x5901, + 0x5901,0x5901,0x5901,0x5704,0x5901,0x5901,0x5901,0x5901,0x5804,0x8004, + 0x5804,0x5804,0x5804,0x5804,0x5804,0x5B01,0x5B01,0x5B01,0x5B01,0x5904, + 0x8004,0x5904,0x6001,0x6001,0x6001,0x6001,0x5A01,0x5A01,0x5A01,0x5A01, + 0x5901,0x5901,0x5901,0x5901,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604, + 0x8004,0x5604,0x5604,0x5604,0x5604,0x5604,0x5901,0x5901,0x5901,0x5901, + 0x5704,0x8004,0x5304,0x5704,0x5504,0x5304,0x5204,0x5201,0x5201,0x5201, + 0x5201,0x5104,0x8004,0x5104,0x5104,0x5104,0x5104,0x5104,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x8004,0x4201,0x4201,0x4201,0x4201,0x4401,0x4401, + 0x4401,0x4401,0x4601,0x4601,0x4601,0x4601,0x4701,0x4701,0x4701,0x4701, + 0x4901,0x4901,0x4901,0x4901,0x5001,0x5001,0x5001,0x5001,0x4A04,0x8004, + 0x4601,0x4601,0x4601,0x4601,0x4701,0x4701,0x4701,0x4701,0x4901,0x4901, + 0x4901,0x4901,0x4A01,0x4A01,0x4A01,0x4A01,0x5101,0x5101,0x5101,0x5101, + 0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5201,0x5201,0x5201,0x5201, + 0x5401,0x5401,0x5401,0x5401,0x5601,0x5601,0x5601,0x5601,0x5701,0x5701, + 0x5701,0x5701,0x5901,0x5901,0x5901,0x5901,0x5A01,0x5A01,0x5A01,0x5A01, + 0x5A01,0x5A01,0x5A01,0x5A01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5B01,0x6001,0x6001,0x6001,0x6001,0x6001,0x6001,0x6001,0x6001, + 0x6108,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6210,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5602,0x5708, + 0x8004,0x5204,0x5708,0x8004,0x5204,0x5704,0x5204,0x5704,0x5B04,0x6208, + 0x8008,0x6008,0x8004,0x5904,0x6008,0x8004,0x5904,0x6004,0x5904,0x5604, + 0x5904,0x5208,0x8008,0x5704,0x8004,0x570C,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5904,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604,0x560C,0x5901,0x5901, + 0x5901,0x5901,0x6004,0x5604,0x5901,0x5901,0x5901,0x5901,0x5704,0x570C, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5904,0x5704,0x5701,0x5701,0x5701,0x5701, + 0x5604,0x560C,0x5901,0x5901,0x5901,0x5901,0x6004,0x5604,0x5704,0x5704, + 0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5602,0x5704,0x5704,0x5901, + 0x5901,0x5901,0x5901,0x5701,0x5701,0x5902,0x5B04,0x5B04,0x6001,0x6001, + 0x6001,0x6001,0x5B01,0x5B01,0x6001,0x6001,0x6208,0x8008,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5410,0x5008,0x5008,0x4B08,0x4B08,0x4908, + 0x4908,0x4701,0x4701,0x4701,0x4701,0x4604,0x4404,0x4604,0x4704,0x8004, + 0x4904,0x8004,0x4B04,0x800C,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5410,0x5201,0x5201,0x5201,0x5201,0x5004,0x5004,0x5004,0x5001,0x5001, + 0x5001,0x5001,0x4B04,0x4B04,0x4B04,0x4B01,0x4B01,0x4B01,0x4B01,0x4904, + 0x4904,0x4904,0x4701,0x4701,0x4701,0x4701,0x4604,0x4404,0x4604,0x4714, + 0x4701,0x4701,0x4601,0x4701,0x4901,0x4901,0x4901,0x4901,0x4604,0x4B14, + 0x4B01,0x4B01,0x4901,0x4B01,0x5001,0x5001,0x5001,0x5001,0x4904,0x5210, + 0x5408,0x5608,0x5708,0x5908,0x5B08,0x5108,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x5904,0x6101, + 0x6101,0x6101,0x6101,0x6101,0x6101,0x5902,0x5101,0x5101,0x5101,0x5101, + 0x5101,0x5101,0x5902,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201,0x6201, + 0x6201,0x6201,0x6201,0x6201,0x6201,0x5904,0x6101,0x6101,0x6101,0x6101, + 0x6101,0x6101,0x5902,0x5101,0x5101,0x5101,0x5101,0x5101,0x5101,0x5902, + 0x6204,0x5904,0x6104,0x5904,0x6204,0x5904,0x6104,0x5904,0x6204,0x4204, + 0x4204,0x4204,0x4208,0x8008,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5201,0x5001,0x5001,0x4B01,0x4B01,0x4901,0x4901, + 0x4704,0x8004,0x5404,0x8004,0x5004,0x8004,0x4904,0x8004,0x5204,0x800C, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5901,0x5901,0x5701,0x5701,0x5601,0x5601,0x5404,0x8004,0x6004,0x8004, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01, + 0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5B01,0x5908,0x8008,0x8004,0x6204, + 0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6204,0x6204, + 0x6201,0x6201,0x6201,0x6201,0x6001,0x6001,0x6001,0x6001,0x5901,0x5901, + 0x5901,0x5901,0x5604,0x5601,0x5601,0x5601,0x5601,0x5704,0x8004,0x5404, + 0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x4604,0x4708,0x8004,0x5204, + 0x5701,0x5701,0x5701,0x5701,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204, + 0x5204,0x5204,0x5204,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004, + 0x5204,0x5704,0x5604,0x5404,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204, + 0x8004,0x5204,0x5204,0x5204,0x5204,0x5204,0x5401,0x5401,0x5401,0x5401, + 0x5204,0x8008,0x540A,0x5201,0x5201,0x5001,0x5001,0x4B01,0x4B01,0x5008, + 0x8008,0x520A,0x5001,0x5001,0x4B01,0x4B01,0x4901,0x4901,0x4B08,0x8008, + 0x5401,0x5401,0x5401,0x5401,0x5601,0x5601,0x5701,0x5701,0x5604,0x5404, + 0x5401,0x5401,0x5401,0x5401,0x5204,0x4B04,0x5204,0x5201,0x5201,0x5201, + 0x5201,0x5004,0x4B04,0x4904,0x4708,0x8004,0x5204,0x5701,0x5701,0x5701, + 0x5701,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5401,0x5401,0x5204, + 0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5204,0x5204,0x5204, + 0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5701,0x5701, + 0x5701,0x5701,0x5601,0x5601,0x5601,0x5601,0x5401,0x5401,0x5401,0x5401, + 0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8004,0x5204,0x5204,0x5204, + 0x5204,0x5204,0x5401,0x5401,0x5401,0x5401,0x5204,0x8008,0x640A,0x6201, + 0x6201,0x6001,0x6001,0x5B01,0x5B01,0x6008,0x8008,0x620A,0x6001,0x6001, + 0x5B01,0x5B01,0x5901,0x5901,0x5B08,0x8008,0x5401,0x5401,0x5401,0x5401, + 0x5601,0x5601,0x5701,0x5701,0x5604,0x5404,0x5204,0x5704,0x5B04,0x6204, + 0x6201,0x6201,0x6201,0x6201,0x6004,0x5B04,0x5904,0x5704,0x4204,0x4404, + 0x4604,0x4704,0x4704,0x4901,0x4901,0x4901,0x4901,0x4701,0x4701,0x4901, + 0x4901,0x4B04,0x4604,0x4704,0x4904,0x4B04,0x4B04,0x5001,0x5001,0x5001, + 0x5001,0x4B01,0x4B01,0x5001,0x5001,0x5204,0x5204,0x5301,0x5301,0x5301, + 0x5301,0x5101,0x5101,0x5301,0x5301,0x5408,0x8008,0x440C,0x4904,0x4704, + 0x4604,0x4404,0x4204,0x5201,0x5201,0x5201,0x5201,0x5101,0x5101,0x5101, + 0x5101,0x5001,0x5001,0x5001,0x5001,0x4B01,0x4B01,0x4B01,0x4B01,0x5201, + 0x5201,0x5201,0x5201,0x5101,0x5101,0x5101,0x5101,0x5001,0x5001,0x5001, + 0x5001,0x4B04,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4401,0x4401,0x4904,0x4701,0x4701,0x4701,0x4701,0x4601, + 0x4601,0x4601,0x4601,0x4401,0x4401,0x4401,0x4401,0x4204,0x5201,0x5201, + 0x5201,0x5201,0x5401,0x5401,0x5401,0x5401,0x5601,0x5601,0x5601,0x5601, + 0x5701,0x5701,0x5701,0x5701,0x5201,0x5201,0x5201,0x5201,0x5401,0x5401, + 0x5401,0x5401,0x5601,0x5601,0x5601,0x5601,0x5704,0x5908,0x8008,0x6208, + 0x8008,0x5708,0x8004,0x5204,0x4B04,0x4704,0x4B04,0x5204,0x5704,0x5204, + 0x5704,0x5B04,0x6208,0x5608,0x5708,0x8004,0x5204,0x4B04,0x4704,0x4B04, + 0x5204,0x5704,0x5204,0x5704,0x5B04,0x6208,0x5608,0x5708,0x8008,0x5708, + 0x8008,0x5708,0x4706,0x4702,0x4708,0x8008, + 0x0000 +}; + +const unsigned Voice2 [] = { + 0x4708,0x8004,0x4204,0x4708,0x8004,0x4204,0x4704,0x4204,0x4704,0x4B04, + 0x5208,0x8008,0x5008,0x8004,0x4904,0x5008,0x8004,0x4904,0x5004,0x4904, + 0x4604,0x4904,0x4208,0x8008,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4904,0x4904,0x4904,0x4904,0x4901,0x4901,0x4901,0x4901, + 0x5004,0x4601,0x4601,0x4601,0x4601,0x4904,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4904,0x4904,0x4904,0x4904,0x4901,0x4901, + 0x4901,0x4901,0x5004,0x4601,0x4601,0x4601,0x4601,0x4904,0x4210,0x4210, + 0x4210,0x4208,0x8028,0x3610,0x3710,0x4008,0x4008,0x3908,0x3208,0x3204, + 0x8004,0x4204,0x8004,0x4208,0x8028,0x4601,0x4601,0x4601,0x4601,0x4601, + 0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601, + 0x4601,0x4710,0x4008,0x4004,0x4004,0x3908,0x3904,0x3904,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4904,0x4904,0x4704,0x4704,0x4604,0x4604,0x4704,0x4704,0x4404,0x4404, + 0x4210,0x4410,0x4210,0x4410,0x4604,0x4704,0x4904,0x4704,0x4604,0x4704, + 0x4904,0x4604,0x4B04,0x4904,0x4704,0x4904,0x4B04,0x4904,0x4804,0x4B04, + 0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x3904, + 0x3904,0x3904,0x3908,0x8020,0x4604,0x8004,0x3B04,0x8004,0x4704,0x8004, + 0x4404,0x8004,0x4104,0x800C,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4204,0x8004,0x4404,0x8004,0x4201,0x4201,0x4201,0x4201, + 0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201, + 0x4201,0x4201,0x4108,0x8010,0x4101,0x4101,0x4101,0x4101,0x4101,0x4101, + 0x4101,0x4101,0x4204,0x8004,0x4604,0x8004,0x3B04,0x8004,0x3704,0x8004, + 0x3408,0x8004,0x4404,0x4704,0x4604,0x8004,0x5704,0x5701,0x5701,0x5701, + 0x5701,0x5604,0x8004,0x4704,0x4204,0x4204,0x4404,0x4404,0x4604,0x4604, + 0x4204,0x4204,0x4104,0x4104,0x4204,0x4204,0x4404,0x4404,0x4104,0x4104, + 0x4204,0x4204,0x4404,0x4404,0x4604,0x4604,0x4204,0x4204,0x4104,0x4104, + 0x4204,0x4204,0x4404,0x4404,0x4104,0x4104,0x4204,0x4204,0x4604,0x4404, + 0x4304,0x3B04,0x4104,0x4304,0x4404,0x4704,0x4404,0x4204,0x4104,0x3904, + 0x3B04,0x4104,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204, + 0x5204,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4704,0x4604,0x4204, + 0x4404,0x4404,0x4604,0x4604,0x4204,0x4204,0x4104,0x4104,0x4204,0x4204, + 0x4404,0x4404,0x4104,0x4104,0x4204,0x4204,0x4404,0x4404,0x4604,0x4604, + 0x4204,0x4204,0x4104,0x4104,0x4204,0x4204,0x4404,0x4404,0x4104,0x4104, + 0x4204,0x4204,0x4604,0x4404,0x4304,0x3B04,0x4104,0x4304,0x4404,0x4704, + 0x4404,0x4204,0x4104,0x3904,0x3B04,0x4104,0x4204,0x5204,0x5204,0x5204, + 0x5204,0x5204,0x5204,0x5204,0x5204,0x4904,0x4904,0x4904,0x4904,0x4904, + 0x4904,0x4704,0x4604,0x3904,0x3B04,0x4104,0x4204,0x4204,0x4404,0x4404, + 0x4604,0x4104,0x4204,0x4404,0x4604,0x4604,0x4704,0x4704,0x4904,0x4904, + 0x4A04,0x4A04,0x4B08,0x8008,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4201,0x4201, + 0x4201,0x4201,0x4104,0x5204,0x8004,0x5204,0x8004,0x5204,0x800C,0x4708, + 0x8004,0x4204,0x4708,0x8004,0x4204,0x4704,0x4204,0x4704,0x4B04,0x5208, + 0x8008,0x5008,0x8004,0x4904,0x5008,0x8004,0x4904,0x5004,0x4904,0x4604, + 0x4904,0x4208,0x8008,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4904,0x4904,0x4904,0x4904,0x4901,0x4901,0x4901,0x4901,0x5004, + 0x4601,0x4601,0x4601,0x4601,0x4904,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4704,0x4904,0x4904,0x4904,0x4904,0x4901,0x4901,0x4901, + 0x4901,0x5004,0x4601,0x4601,0x4601,0x4601,0x4904,0x4210,0x4210,0x4210, + 0x4208,0x8028,0x3610,0x3710,0x4008,0x4008,0x3908,0x3208,0x3204,0x8004, + 0x4204,0x8004,0x4208,0x8028,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601, + 0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601, + 0x4710,0x4008,0x4004,0x4004,0x3908,0x3904,0x3904,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4904, + 0x4904,0x4704,0x4704,0x4604,0x4604,0x4704,0x4704,0x4404,0x4404,0x4210, + 0x4410,0x4210,0x4410,0x4604,0x4704,0x4904,0x4704,0x4604,0x4704,0x4904, + 0x4604,0x4B04,0x4904,0x4704,0x4904,0x4B04,0x4904,0x4804,0x4B04,0x4904, + 0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x3904,0x3904, + 0x3904,0x3908,0x8020,0x4604,0x8004,0x3B04,0x8004,0x4704,0x8004,0x4404, + 0x8004,0x4104,0x800C,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4204,0x8004,0x4404,0x8004,0x4201,0x4201,0x4201,0x4201,0x4201, + 0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201, + 0x4201,0x4108,0x8010,0x4101,0x4101,0x4101,0x4101,0x4101,0x4101,0x4101, + 0x4101,0x4204,0x8004,0x4604,0x8004,0x3B04,0x8004,0x3704,0x8004,0x3408, + 0x8004,0x4404,0x4704,0x4604,0x8004,0x5704,0x5701,0x5701,0x5701,0x5701, + 0x5604,0x8004,0x4704,0x4204,0x4204,0x4404,0x4404,0x4604,0x4604,0x4204, + 0x4204,0x4104,0x4104,0x4204,0x4204,0x4404,0x4404,0x4104,0x4104,0x4204, + 0x4204,0x4404,0x4404,0x4604,0x4604,0x4204,0x4204,0x4104,0x4104,0x4204, + 0x4204,0x4404,0x4404,0x4104,0x4104,0x4204,0x4204,0x4604,0x4404,0x4304, + 0x3B04,0x4104,0x4304,0x4404,0x4704,0x4404,0x4204,0x4104,0x3904,0x3B04, + 0x4104,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204,0x5204, + 0x4904,0x4904,0x4904,0x4904,0x4904,0x4904,0x4704,0x4604,0x4204,0x4404, + 0x4404,0x4604,0x4604,0x4204,0x4204,0x4104,0x4104,0x4204,0x4204,0x4404, + 0x4404,0x4104,0x4104,0x4204,0x4204,0x4404,0x4404,0x4604,0x4604,0x4204, + 0x4204,0x4104,0x4104,0x4204,0x4204,0x4404,0x4404,0x4104,0x4104,0x4204, + 0x4204,0x4604,0x4404,0x4304,0x3B04,0x4104,0x4304,0x4404,0x4704,0x4404, + 0x4204,0x4104,0x3904,0x3B04,0x4104,0x4204,0x5204,0x5204,0x5204,0x5204, + 0x5204,0x5204,0x5204,0x5204,0x4904,0x4904,0x4904,0x4904,0x4904,0x4904, + 0x4704,0x4604,0x3904,0x3B04,0x4104,0x4204,0x4204,0x4404,0x4404,0x4604, + 0x4104,0x4204,0x4404,0x4604,0x4604,0x4704,0x4704,0x4904,0x4904,0x4A04, + 0x4A04,0x4B08,0x8008,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401, + 0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4401,0x4201,0x4201,0x4201, + 0x4201,0x4104,0x5204,0x8004,0x5204,0x8004,0x5204,0x800C,0x4208,0x8004, + 0x3904,0x4208,0x8004,0x3904,0x4204,0x3904,0x4204,0x4604,0x4908,0x8008, + 0x4908,0x8004,0x4604,0x4908,0x8004,0x4604,0x4904,0x4604,0x4304,0x4604, + 0x3B08,0x8008,0x4004,0x4004,0x4204,0x4204,0x4404,0x4404,0x4004,0x4004, + 0x3B04,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04,0x3B04,0x4004,0x4004, + 0x4204,0x4204,0x4404,0x4404,0x4004,0x4004,0x3B04,0x3B04,0x4004,0x4004, + 0x4204,0x4204,0x3B04,0x3B04,0x4004,0x4004,0x4204,0x4204,0x4404,0x4404, + 0x4004,0x4004,0x3B04,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04,0x3B04, + 0x3904,0x3904,0x3B04,0x3B04,0x4004,0x4004,0x3904,0x3904,0x3904,0x3904, + 0x3A04,0x3A04,0x4004,0x4004,0x3904,0x3904,0x3704,0x3704,0x3604,0x3604, + 0x3704,0x3704,0x4604,0x4604,0x4704,0x4704,0x4604,0x4604,0x4704,0x3704, + 0x3604,0x3704,0x3908,0x8004,0x3201,0x3201,0x3201,0x3201,0x3401,0x3401, + 0x3401,0x3401,0x3601,0x3601,0x3601,0x3601,0x3701,0x3701,0x3701,0x3701, + 0x3901,0x3901,0x3901,0x3901,0x4001,0x4001,0x4001,0x4001,0x3A04,0x8004, + 0x3601,0x3601,0x3601,0x3601,0x3701,0x3701,0x3701,0x3701,0x3901,0x3901, + 0x3901,0x3901,0x3A01,0x3A01,0x3A01,0x3A01,0x4101,0x4101,0x4101,0x4101, + 0x4401,0x4401,0x4401,0x4401,0x4204,0x8038,0x4B04,0x4B04,0x4B01,0x4B01, + 0x4B01,0x4B01,0x5004,0x4904,0x4904,0x4901,0x4901,0x4901,0x4901,0x4B04, + 0x4704,0x4704,0x4701,0x4701,0x4701,0x4701,0x4B04,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4904,0x4704,0x4204,0x3B08,0x8004,0x4204,0x4708,0x8004,0x4204, + 0x4704,0x4204,0x4704,0x4B04,0x5208,0x8008,0x5008,0x8004,0x4904,0x5008, + 0x8004,0x4904,0x5004,0x4904,0x4604,0x4904,0x4208,0x8008,0x4704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4701,0x4701,0x4701,0x4701,0x4B04,0x4401,0x4401,0x4401,0x4401,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4701,0x4701,0x4701,0x4701,0x4B04,0x4401,0x4401,0x4401, + 0x4401,0x4704,0x4210,0x4210,0x4210,0x4208,0x8028,0x3610,0x3710,0x4008, + 0x4008,0x3908,0x3908,0x3204,0x8004,0x4204,0x8004,0x4208,0x8028,0x4601, + 0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601, + 0x4601,0x4601,0x4601,0x4601,0x4601,0x4710,0x4008,0x4004,0x4004,0x3908, + 0x3904,0x3904,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4904,0x4904,0x4704,0x4704,0x4604,0x4604, + 0x4704,0x4704,0x4404,0x4404,0x4210,0x4410,0x4210,0x4410,0x4208,0x4408, + 0x4208,0x4408,0x4204,0x3204,0x3204,0x3204,0x3208,0x8020,0x3B04,0x8004, + 0x3404,0x8004,0x4004,0x8004,0x3904,0x8004,0x3604,0x800C,0x4901,0x4901, + 0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4704,0x8004,0x4904,0x8004, + 0x4B10,0x4908,0x8008,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5001,0x5001,0x4B01,0x4B01,0x4901,0x4901,0x4704, + 0x8004,0x5404,0x8004,0x5004,0x8004,0x4904,0x8004,0x5208,0x8004,0x5004, + 0x5001,0x5001,0x5001,0x5001,0x4B04,0x8004,0x5004,0x5001,0x5001,0x5001, + 0x5001,0x4B04,0x8004,0x4004,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04, + 0x3704,0x3704,0x3604,0x3604,0x3704,0x3704,0x3904,0x3904,0x3604,0x3604, + 0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04,0x3704,0x3704,0x3604,0x3604, + 0x3704,0x3704,0x3904,0x3904,0x3604,0x3604,0x3704,0x4704,0x4B04,0x4904, + 0x4804,0x4404,0x4604,0x4804,0x4904,0x5004,0x4904,0x4704,0x4604,0x4204, + 0x4404,0x4604,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4204,0x4204,0x4204,0x4204,0x4204,0x4204,0x4004,0x3B04,0x3704, + 0x3904,0x3904,0x3B04,0x3B04,0x3704,0x3704,0x3604,0x3604,0x3704,0x3704, + 0x3904,0x3904,0x3604,0x3604,0x3704,0x4704,0x4904,0x4904,0x4B04,0x4B04, + 0x4704,0x4704,0x4604,0x4604,0x4704,0x4704,0x4904,0x4904,0x4604,0x4604, + 0x4704,0x4704,0x4B04,0x4904,0x4804,0x4404,0x4604,0x4804,0x4904,0x5004, + 0x4904,0x4704,0x4604,0x4204,0x4404,0x4604,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4701,0x4701,0x4701,0x4701,0x4904,0x5004, + 0x5004,0x5004,0x5004,0x5004,0x4B04,0x4904,0x4204,0x4404,0x4604,0x4704, + 0x4704,0x4904,0x4904,0x4B04,0x3604,0x3704,0x3904,0x3B04,0x3B04,0x4004, + 0x4004,0x4004,0x4004,0x4104,0x4104,0x4208,0x8008,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3701,0x3701,0x3701,0x3701,0x3604,0x3708,0x8018,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3701,0x3701,0x3701,0x3701,0x3604,0x3708,0x8008,0x4708, + 0x8008,0x4408,0x8008,0x4708,0x8008,0x3710,0x3710,0x3710,0x3708,0x3908, + 0x3710,0x3710,0x3710,0x3708,0x3908,0x3704,0x3B04,0x4204,0x4704,0x4B04, + 0x4704,0x5204,0x4B04,0x4708,0x3706,0x3702,0x3708,0x8008,0x4208,0x8004, + 0x3904,0x4208,0x8004,0x3904,0x4204,0x3904,0x4204,0x4604,0x4908,0x8008, + 0x4908,0x8004,0x4604,0x4908,0x8004,0x4604,0x4904,0x4604,0x4304,0x4604, + 0x3B08,0x8008,0x4004,0x4004,0x4204,0x4204,0x4404,0x4404,0x4004,0x4004, + 0x3B04,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04,0x3B04,0x4004,0x4004, + 0x4204,0x4204,0x4404,0x4404,0x4004,0x4004,0x3B04,0x3B04,0x4004,0x4004, + 0x4204,0x4204,0x3B04,0x3B04,0x4004,0x4004,0x4204,0x4204,0x4404,0x4404, + 0x4004,0x4004,0x3B04,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04,0x3B04, + 0x3904,0x3904,0x3B04,0x3B04,0x4004,0x4004,0x3904,0x3904,0x3904,0x3904, + 0x3A04,0x3A04,0x4004,0x4004,0x3904,0x3904,0x3704,0x3704,0x3604,0x3604, + 0x3704,0x3704,0x4604,0x4604,0x4704,0x4704,0x4604,0x4604,0x4704,0x3704, + 0x3604,0x3704,0x3908,0x8004,0x3201,0x3201,0x3201,0x3201,0x3401,0x3401, + 0x3401,0x3401,0x3601,0x3601,0x3601,0x3601,0x3701,0x3701,0x3701,0x3701, + 0x3901,0x3901,0x3901,0x3901,0x4001,0x4001,0x4001,0x4001,0x3A04,0x8004, + 0x3601,0x3601,0x3601,0x3601,0x3701,0x3701,0x3701,0x3701,0x3901,0x3901, + 0x3901,0x3901,0x3A01,0x3A01,0x3A01,0x3A01,0x4101,0x4101,0x4101,0x4101, + 0x4401,0x4401,0x4401,0x4401,0x4204,0x8038,0x4B04,0x4B04,0x4B01,0x4B01, + 0x4B01,0x4B01,0x5004,0x4904,0x4904,0x4901,0x4901,0x4901,0x4901,0x4B04, + 0x4704,0x4704,0x4701,0x4701,0x4701,0x4701,0x4B04,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4904,0x4704,0x4204,0x3B08,0x8004,0x4204,0x4708,0x8004,0x4204, + 0x4704,0x4204,0x4704,0x4B04,0x5208,0x8008,0x5008,0x8004,0x4904,0x5008, + 0x8004,0x4904,0x5004,0x4904,0x4604,0x4904,0x4208,0x8008,0x4704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4701,0x4701,0x4701,0x4701,0x4B04,0x4401,0x4401,0x4401,0x4401,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4701,0x4701,0x4701,0x4701,0x4B04,0x4401,0x4401,0x4401, + 0x4401,0x4704,0x4210,0x4210,0x4210,0x4208,0x8028,0x3610,0x3710,0x4008, + 0x4008,0x3908,0x3908,0x3204,0x8004,0x4204,0x8004,0x4208,0x8028,0x4601, + 0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601,0x4601, + 0x4601,0x4601,0x4601,0x4601,0x4601,0x4710,0x4008,0x4004,0x4004,0x3908, + 0x3904,0x3904,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4904,0x4904,0x4704,0x4704,0x4604,0x4604, + 0x4704,0x4704,0x4404,0x4404,0x4210,0x4410,0x4210,0x4410,0x4208,0x4408, + 0x4208,0x4408,0x4204,0x3204,0x3204,0x3204,0x3208,0x8020,0x3B04,0x8004, + 0x3404,0x8004,0x4004,0x8004,0x3904,0x8004,0x3604,0x800C,0x4901,0x4901, + 0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4704,0x8004,0x4904,0x8004, + 0x4B10,0x4908,0x8008,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201,0x5201, + 0x5201,0x5201,0x5201,0x5001,0x5001,0x4B01,0x4B01,0x4901,0x4901,0x4704, + 0x8004,0x5404,0x8004,0x5004,0x8004,0x4904,0x8004,0x5208,0x8004,0x5004, + 0x5001,0x5001,0x5001,0x5001,0x4B04,0x8004,0x5004,0x5001,0x5001,0x5001, + 0x5001,0x4B04,0x8004,0x4004,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04, + 0x3704,0x3704,0x3604,0x3604,0x3704,0x3704,0x3904,0x3904,0x3604,0x3604, + 0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04,0x3704,0x3704,0x3604,0x3604, + 0x3704,0x3704,0x3904,0x3904,0x3604,0x3604,0x3704,0x4704,0x4B04,0x4904, + 0x4804,0x4404,0x4604,0x4804,0x4904,0x5004,0x4904,0x4704,0x4604,0x4204, + 0x4404,0x4604,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4204,0x4204,0x4204,0x4204,0x4204,0x4204,0x4004,0x3B04,0x3704, + 0x3904,0x3904,0x3B04,0x3B04,0x3704,0x3704,0x3604,0x3604,0x3704,0x3704, + 0x3904,0x3904,0x3604,0x3604,0x3704,0x4704,0x4904,0x4904,0x4B04,0x4B04, + 0x4704,0x4704,0x4604,0x4604,0x4704,0x4704,0x4904,0x4904,0x4604,0x4604, + 0x4704,0x4704,0x4B04,0x4904,0x4804,0x4404,0x4604,0x4804,0x4904,0x5004, + 0x4904,0x4704,0x4604,0x4204,0x4404,0x4604,0x4704,0x4704,0x4704,0x4704, + 0x4704,0x4704,0x4704,0x4704,0x4701,0x4701,0x4701,0x4701,0x4904,0x5004, + 0x5004,0x5004,0x5004,0x5004,0x4B04,0x4904,0x4204,0x4404,0x4604,0x4704, + 0x4704,0x4904,0x4904,0x4B04,0x3604,0x3704,0x3904,0x3B04,0x3B04,0x4004, + 0x4004,0x4004,0x4004,0x4104,0x4104,0x4208,0x8008,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3701,0x3701,0x3701,0x3701,0x3604,0x3708,0x8018,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3701,0x3701,0x3701,0x3701,0x3604,0x3708,0x8008,0x4708, + 0x8008,0x4408,0x8008,0x4708,0x8008,0x3710,0x3710,0x3710,0x3708,0x3908, + 0x3710,0x3710,0x3710,0x3708,0x3908,0x3704,0x3B04,0x4204,0x4704,0x4B04, + 0x4704,0x5204,0x4B04,0x4708,0x3706,0x3702,0x3708,0x8008, + 0x0000 +}; + +const unsigned Voice3 [] = { + 0x3708,0x8004,0x3204,0x3708,0x8004,0x3204,0x3704,0x3204,0x3704,0x3B04, + 0x3208,0x8008,0x4008,0x8004,0x3904,0x4008,0x8004,0x3904,0x4004,0x3904, + 0x3604,0x4904,0x4208,0x8008,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3904,0x3904, + 0x3B04,0x3B04,0x3604,0x3604,0x3704,0x3704,0x3904,0x3904,0x3B08,0x8028, + 0x3210,0x3410,0x3008,0x3008,0x3208,0x3208,0x2B04,0x8004,0x3204,0x8004, + 0x3708,0x8008,0x4B10,0x5010,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201, + 0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201, + 0x3410,0x3008,0x3008,0x3208,0x3208,0x3B14,0x3B02,0x3901,0x3B01,0x4004, + 0x3904,0x4714,0x4702,0x4601,0x4701,0x4904,0x4604,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3604,0x3604,0x3704, + 0x3704,0x3404,0x3404,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204, + 0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204, + 0x3404,0x3604,0x3404,0x3204,0x3404,0x3604,0x3204,0x3704,0x3904,0x3B04, + 0x3904,0x3704,0x3904,0x3B04,0x3804,0x3904,0x3904,0x3904,0x3904,0x3904, + 0x3904,0x3904,0x3904,0x3904,0x2904,0x2904,0x2904,0x2908,0x8008,0x490A, + 0x4702,0x4602,0x4402,0x4204,0x8004,0x3304,0x8004,0x3404,0x8004,0x3204, + 0x8004,0x3104,0x8004,0x2904,0x800C,0x2A01,0x2A01,0x2A01,0x2A01,0x2A01, + 0x2A01,0x2A01,0x2A01,0x2B04,0x8004,0x2704,0x8004,0x2908,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901, + 0x3801,0x3801,0x3801,0x3801,0x3701,0x3701,0x3701,0x3701,0x3401,0x3401, + 0x3401,0x3401,0x3204,0x8004,0x3404,0x8004,0x3604,0x8004,0x3304,0x8004, + 0x3404,0x8004,0x3204,0x8004,0x3104,0x8004,0x2904,0x8004,0x2B04,0x8004, + 0x3704,0x8004,0x3904,0x8004,0x2904,0x8004,0x4604,0x4604,0x4704,0x4704, + 0x4904,0x4904,0x4604,0x4604,0x4404,0x4404,0x4604,0x4604,0x4704,0x4704, + 0x4404,0x4404,0x4604,0x4604,0x4704,0x4704,0x4904,0x4904,0x4604,0x4604, + 0x4404,0x4404,0x4604,0x4604,0x4704,0x4704,0x4404,0x4404,0x4608,0x8008, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5408,0x8008,0x5401,0x5401, + 0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401, + 0x5401,0x5401,0x5401,0x5401,0x5204,0x5604,0x5704,0x5904,0x5701,0x5701, + 0x5701,0x5701,0x5901,0x5901,0x5B01,0x5B01,0x5904,0x5704,0x5701,0x5701, + 0x5701,0x5701,0x5604,0x5204,0x5604,0x5601,0x5601,0x5601,0x5601,0x5404, + 0x5204,0x5104,0x5204,0x4604,0x4704,0x4704,0x4904,0x4904,0x4604,0x4604, + 0x4404,0x4404,0x4604,0x4604,0x4704,0x4704,0x4404,0x4404,0x4604,0x4604, + 0x4704,0x4704,0x4904,0x4904,0x4604,0x4604,0x4404,0x4404,0x4604,0x4604, + 0x4704,0x4704,0x4404,0x4404,0x4608,0x8008,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5408,0x8008,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401, + 0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401, + 0x5204,0x5504,0x5704,0x5904,0x5701,0x5701,0x5701,0x5701,0x5901,0x5901, + 0x5B01,0x5B01,0x5904,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604,0x5204, + 0x5604,0x5601,0x5601,0x5601,0x5601,0x5404,0x5204,0x5104,0x3204,0x2904, + 0x2B04,0x3104,0x3204,0x3204,0x3404,0x3404,0x3604,0x3104,0x3204,0x3404, + 0x3604,0x3604,0x3704,0x3704,0x3904,0x3904,0x3A04,0x3A04,0x3B08,0x8008, + 0x3710,0x3910,0x4204,0x8004,0x4204,0x8004,0x4204,0x800C,0x3708,0x8004, + 0x3204,0x3708,0x8004,0x3204,0x3704,0x3204,0x3704,0x3B04,0x3208,0x8008, + 0x4008,0x8004,0x3904,0x4008,0x8004,0x3904,0x4004,0x3904,0x3604,0x4904, + 0x4208,0x8008,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04, + 0x3604,0x3604,0x3704,0x3704,0x3904,0x3904,0x3B08,0x8028,0x3210,0x3410, + 0x3008,0x3008,0x3208,0x3208,0x2B04,0x8004,0x3204,0x8004,0x3708,0x8008, + 0x4B10,0x5010,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201, + 0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3201,0x3410,0x3008, + 0x3008,0x3208,0x3208,0x3B14,0x3B02,0x3901,0x3B01,0x4004,0x3904,0x4714, + 0x4702,0x4601,0x4701,0x4904,0x4604,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3604,0x3604,0x3704,0x3704,0x3404, + 0x3404,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204, + 0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3204,0x3404,0x3604, + 0x3404,0x3204,0x3404,0x3604,0x3204,0x3704,0x3904,0x3B04,0x3904,0x3704, + 0x3904,0x3B04,0x3804,0x3904,0x3904,0x3904,0x3904,0x3904,0x3904,0x3904, + 0x3904,0x3904,0x2904,0x2904,0x2904,0x2908,0x8008,0x490A,0x4702,0x4602, + 0x4402,0x4204,0x8004,0x3304,0x8004,0x3404,0x8004,0x3204,0x8004,0x3104, + 0x8004,0x2904,0x800C,0x2A01,0x2A01,0x2A01,0x2A01,0x2A01,0x2A01,0x2A01, + 0x2A01,0x2B04,0x8004,0x2704,0x8004,0x2908,0x3901,0x3901,0x3901,0x3901, + 0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3901,0x3801,0x3801, + 0x3801,0x3801,0x3701,0x3701,0x3701,0x3701,0x3401,0x3401,0x3401,0x3401, + 0x3204,0x8004,0x3404,0x8004,0x3604,0x8004,0x3304,0x8004,0x3404,0x8004, + 0x3204,0x8004,0x3104,0x8004,0x2904,0x8004,0x2B04,0x8004,0x3704,0x8004, + 0x3904,0x8004,0x2904,0x8004,0x4604,0x4604,0x4704,0x4704,0x4904,0x4904, + 0x4604,0x4604,0x4404,0x4404,0x4604,0x4604,0x4704,0x4704,0x4404,0x4404, + 0x4604,0x4604,0x4704,0x4704,0x4904,0x4904,0x4604,0x4604,0x4404,0x4404, + 0x4604,0x4604,0x4704,0x4704,0x4404,0x4404,0x4608,0x8008,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5408,0x8008,0x5401,0x5401,0x5401,0x5401, + 0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401, + 0x5401,0x5401,0x5204,0x5604,0x5704,0x5904,0x5701,0x5701,0x5701,0x5701, + 0x5901,0x5901,0x5B01,0x5B01,0x5904,0x5704,0x5701,0x5701,0x5701,0x5701, + 0x5604,0x5204,0x5604,0x5601,0x5601,0x5601,0x5601,0x5404,0x5204,0x5104, + 0x5204,0x4604,0x4704,0x4704,0x4904,0x4904,0x4604,0x4604,0x4404,0x4404, + 0x4604,0x4604,0x4704,0x4704,0x4404,0x4404,0x4604,0x4604,0x4704,0x4704, + 0x4904,0x4904,0x4604,0x4604,0x4404,0x4404,0x4604,0x4604,0x4704,0x4704, + 0x4404,0x4404,0x4608,0x8008,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601,0x5601, + 0x5408,0x8008,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401, + 0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5401,0x5204,0x5504, + 0x5704,0x5904,0x5701,0x5701,0x5701,0x5701,0x5901,0x5901,0x5B01,0x5B01, + 0x5904,0x5704,0x5701,0x5701,0x5701,0x5701,0x5604,0x5204,0x5604,0x5601, + 0x5601,0x5601,0x5601,0x5404,0x5204,0x5104,0x3204,0x2904,0x2B04,0x3104, + 0x3204,0x3204,0x3404,0x3404,0x3604,0x3104,0x3204,0x3404,0x3604,0x3604, + 0x3704,0x3704,0x3904,0x3904,0x3A04,0x3A04,0x3B08,0x8008,0x3710,0x3910, + 0x4204,0x8004,0x4204,0x8004,0x4204,0x800C,0x3208,0x8004,0x2904,0x3208, + 0x8004,0x2904,0x3204,0x2904,0x3204,0x3604,0x4908,0x8008,0x3908,0x8004, + 0x3604,0x3908,0x8004,0x3604,0x3904,0x3604,0x3304,0x3604,0x2B08,0x8008, + 0x4404,0x4404,0x4504,0x4504,0x4704,0x4704,0x4404,0x4404,0x4204,0x4204, + 0x4404,0x4404,0x4504,0x4504,0x4204,0x4204,0x4404,0x4404,0x4504,0x4504, + 0x4704,0x4704,0x4404,0x4404,0x4204,0x4204,0x4404,0x4404,0x4504,0x4504, + 0x4204,0x4204,0x4404,0x4404,0x4504,0x4504,0x4704,0x4704,0x4404,0x4404, + 0x4204,0x4204,0x4404,0x4404,0x4504,0x4504,0x4204,0x4204,0x4004,0x4004, + 0x4204,0x4204,0x4404,0x4404,0x4004,0x4004,0x4004,0x4004,0x4204,0x4204, + 0x4304,0x4304,0x4004,0x4004,0x3A04,0x3A04,0x3904,0x3904,0x3A04,0x3A04, + 0x4904,0x4904,0x4A04,0x4A04,0x4904,0x4904,0x4A04,0x4A04,0x4904,0x4704, + 0x4608,0x8004,0x2201,0x2201,0x2201,0x2201,0x2401,0x2401,0x2401,0x2401, + 0x2601,0x2601,0x2601,0x2601,0x2701,0x2701,0x2701,0x2701,0x2901,0x2901, + 0x2901,0x2901,0x3001,0x3001,0x3001,0x3001,0x2A04,0x8004,0x2601,0x2601, + 0x2601,0x2601,0x2701,0x2701,0x2701,0x2701,0x2901,0x2901,0x2901,0x2901, + 0x2A01,0x2A01,0x2A01,0x2A01,0x2101,0x2101,0x2101,0x2101,0x3401,0x3401, + 0x3401,0x3401,0x3204,0x8004,0x4204,0x4404,0x4504,0x4704,0x4904,0x4A08, + 0x4B08,0x5008,0x5108,0x5204,0x5204,0x5201,0x5201,0x5201,0x5201,0x5404, + 0x5004,0x5004,0x5001,0x5001,0x5001,0x5001,0x5204,0x4B04,0x4B04,0x4B01, + 0x4B01,0x4B01,0x4B01,0x5204,0x5201,0x5201,0x5201,0x5201,0x5004,0x4B04, + 0x4904,0x4708,0x8004,0x3204,0x3708,0x8004,0x3204,0x3704,0x3204,0x3704, + 0x3B04,0x4208,0x8008,0x4008,0x8004,0x3904,0x4008,0x8004,0x3904,0x4004, + 0x3904,0x3604,0x3904,0x3208,0x8008,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3904, + 0x3904,0x3B04,0x3B04,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04,0x4008, + 0x8008,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x5010,0x4908,0x4908, + 0x4708,0x4708,0x4408,0x4408,0x4008,0x3908,0x4204,0x8004,0x4604,0x8004, + 0x4704,0x800C,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x5010,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4904,0x4904,0x4904,0x4901,0x4901,0x4901,0x4901, + 0x4704,0x4704,0x4704,0x4408,0x4404,0x4404,0x4008,0x4004,0x4004,0x3B14, + 0x3B01,0x3B01,0x3901,0x3B01,0x4001,0x4001,0x4001,0x4001,0x3904,0x4714, + 0x4701,0x4701,0x4601,0x4701,0x4901,0x4901,0x4901,0x4901,0x4604,0x4B10, + 0x5010,0x4B08,0x5210,0x5708,0x5610,0x5710,0x5610,0x5710,0x5608,0x5708, + 0x5608,0x5708,0x5604,0x4204,0x4204,0x4204,0x4208,0x8008,0x4201,0x4201, + 0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4001,0x4001, + 0x3B01,0x3B01,0x3901,0x3901,0x3704,0x8004,0x4404,0x8004,0x4004,0x8004, + 0x3904,0x8004,0x4204,0x800C,0x4B0A,0x4902,0x4702,0x4602,0x5404,0x8004, + 0x5004,0x8004,0x3208,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201, + 0x4201,0x4201,0x4201,0x4201,0x4201,0x4101,0x4101,0x4101,0x4101,0x4001, + 0x4001,0x4001,0x4001,0x3901,0x3901,0x3901,0x3901,0x3704,0x8004,0x3904, + 0x8004,0x3B04,0x8004,0x3804,0x8004,0x3904,0x8004,0x3704,0x8004,0x3604, + 0x8004,0x3204,0x8004,0x3404,0x8004,0x3004,0x8004,0x3204,0x8004,0x3204, + 0x8004,0x2708,0x8018,0x3208,0x8018,0x2708,0x8018,0x3208,0x8018,0x3B08, + 0x8008,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4908,0x8008,0x4901, + 0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901, + 0x4901,0x4901,0x4901,0x4901,0x4901,0x4704,0x4B04,0x5004,0x5204,0x5001, + 0x5001,0x5001,0x5001,0x5201,0x5201,0x5401,0x5401,0x5204,0x5004,0x5001, + 0x5001,0x5001,0x5001,0x4B04,0x4704,0x4B04,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4904,0x4704,0x4604,0x4704,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04, + 0x3B04,0x3904,0x3904,0x3B04,0x3B04,0x4004,0x4004,0x3904,0x3904,0x3B04, + 0x4B04,0x5004,0x5004,0x5204,0x5204,0x4B04,0x4B04,0x4904,0x4904,0x4B04, + 0x4B04,0x5004,0x5004,0x4904,0x4904,0x8004,0x3704,0x3B04,0x3904,0x3804, + 0x3404,0x3604,0x3804,0x3904,0x4004,0x3904,0x3704,0x3604,0x3204,0x3404, + 0x3604,0x3704,0x3704,0x3904,0x3B04,0x4004,0x4004,0x4004,0x4004,0x4204, + 0x4204,0x4204,0x4204,0x3204,0x3204,0x3204,0x3204,0x3704,0x3204,0x3404, + 0x3604,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3604,0x3704,0x3904,0x3B04, + 0x3B04,0x4004,0x4004,0x4204,0x4204,0x4304,0x4304,0x4408,0x8008,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3001,0x3210,0x2708,0x8018,0x3001,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3210,0x2708,0x8018,0x3008,0x8008,0x3208, + 0x8008,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, + 0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, + 0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, + 0x2704,0x2704,0x2704,0x2704,0x2B04,0x3204,0x3704,0x3B04,0x3704,0x4204, + 0x3B04,0x3708,0x2706,0x2702,0x2708,0x8008,0x3208,0x8004,0x2904,0x3208, + 0x8004,0x2904,0x3204,0x2904,0x3204,0x3604,0x4908,0x8008,0x3908,0x8004, + 0x3604,0x3908,0x8004,0x3604,0x3904,0x3604,0x3304,0x3604,0x2B08,0x8008, + 0x4404,0x4404,0x4504,0x4504,0x4704,0x4704,0x4404,0x4404,0x4204,0x4204, + 0x4404,0x4404,0x4504,0x4504,0x4204,0x4204,0x4404,0x4404,0x4504,0x4504, + 0x4704,0x4704,0x4404,0x4404,0x4204,0x4204,0x4404,0x4404,0x4504,0x4504, + 0x4204,0x4204,0x4404,0x4404,0x4504,0x4504,0x4704,0x4704,0x4404,0x4404, + 0x4204,0x4204,0x4404,0x4404,0x4504,0x4504,0x4204,0x4204,0x4004,0x4004, + 0x4204,0x4204,0x4404,0x4404,0x4004,0x4004,0x4004,0x4004,0x4204,0x4204, + 0x4304,0x4304,0x4004,0x4004,0x3A04,0x3A04,0x3904,0x3904,0x3A04,0x3A04, + 0x4904,0x4904,0x4A04,0x4A04,0x4904,0x4904,0x4A04,0x4A04,0x4904,0x4704, + 0x4608,0x8004,0x2201,0x2201,0x2201,0x2201,0x2401,0x2401,0x2401,0x2401, + 0x2601,0x2601,0x2601,0x2601,0x2701,0x2701,0x2701,0x2701,0x2901,0x2901, + 0x2901,0x2901,0x3001,0x3001,0x3001,0x3001,0x2A04,0x8004,0x2601,0x2601, + 0x2601,0x2601,0x2701,0x2701,0x2701,0x2701,0x2901,0x2901,0x2901,0x2901, + 0x2A01,0x2A01,0x2A01,0x2A01,0x2101,0x2101,0x2101,0x2101,0x3401,0x3401, + 0x3401,0x3401,0x3204,0x8004,0x4204,0x4404,0x4504,0x4704,0x4904,0x4A08, + 0x4B08,0x5008,0x5108,0x5204,0x5204,0x5201,0x5201,0x5201,0x5201,0x5404, + 0x5004,0x5004,0x5001,0x5001,0x5001,0x5001,0x5204,0x4B04,0x4B04,0x4B01, + 0x4B01,0x4B01,0x4B01,0x5204,0x5201,0x5201,0x5201,0x5201,0x5004,0x4B04, + 0x4904,0x4708,0x8004,0x3204,0x3708,0x8004,0x3204,0x3704,0x3204,0x3704, + 0x3B04,0x4208,0x8008,0x4008,0x8004,0x3904,0x4008,0x8004,0x3904,0x4004, + 0x3904,0x3604,0x3904,0x3208,0x8008,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704, + 0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3704,0x3904, + 0x3904,0x3B04,0x3B04,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3B04,0x4008, + 0x8008,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x5010,0x4908,0x4908, + 0x4708,0x4708,0x4408,0x4408,0x4008,0x3908,0x4204,0x8004,0x4604,0x8004, + 0x4704,0x800C,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x5010,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4904,0x4904,0x4904,0x4901,0x4901,0x4901,0x4901, + 0x4704,0x4704,0x4704,0x4408,0x4404,0x4404,0x4008,0x4004,0x4004,0x3B14, + 0x3B01,0x3B01,0x3901,0x3B01,0x4001,0x4001,0x4001,0x4001,0x3904,0x4714, + 0x4701,0x4701,0x4601,0x4701,0x4901,0x4901,0x4901,0x4901,0x4604,0x4B10, + 0x5010,0x4B08,0x5210,0x5708,0x5610,0x5710,0x5610,0x5710,0x5608,0x5708, + 0x5608,0x5708,0x5604,0x4204,0x4204,0x4204,0x4208,0x8008,0x4201,0x4201, + 0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4001,0x4001, + 0x3B01,0x3B01,0x3901,0x3901,0x3704,0x8004,0x4404,0x8004,0x4004,0x8004, + 0x3904,0x8004,0x4204,0x800C,0x4B0A,0x4902,0x4702,0x4602,0x5404,0x8004, + 0x5004,0x8004,0x3208,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201,0x4201, + 0x4201,0x4201,0x4201,0x4201,0x4201,0x4101,0x4101,0x4101,0x4101,0x4001, + 0x4001,0x4001,0x4001,0x3901,0x3901,0x3901,0x3901,0x3704,0x8004,0x3904, + 0x8004,0x3B04,0x8004,0x3804,0x8004,0x3904,0x8004,0x3704,0x8004,0x3604, + 0x8004,0x3204,0x8004,0x3404,0x8004,0x3004,0x8004,0x3204,0x8004,0x3204, + 0x8004,0x2708,0x8018,0x3208,0x8018,0x2708,0x8018,0x3208,0x8018,0x3B08, + 0x8008,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4B01,0x4908,0x8008,0x4901, + 0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901,0x4901, + 0x4901,0x4901,0x4901,0x4901,0x4901,0x4704,0x4B04,0x5004,0x5204,0x5001, + 0x5001,0x5001,0x5001,0x5201,0x5201,0x5401,0x5401,0x5204,0x5004,0x5001, + 0x5001,0x5001,0x5001,0x4B04,0x4704,0x4B04,0x4B01,0x4B01,0x4B01,0x4B01, + 0x4904,0x4704,0x4604,0x4704,0x3B04,0x4004,0x4004,0x4204,0x4204,0x3B04, + 0x3B04,0x3904,0x3904,0x3B04,0x3B04,0x4004,0x4004,0x3904,0x3904,0x3B04, + 0x4B04,0x5004,0x5004,0x5204,0x5204,0x4B04,0x4B04,0x4904,0x4904,0x4B04, + 0x4B04,0x5004,0x5004,0x4904,0x4904,0x8004,0x3704,0x3B04,0x3904,0x3804, + 0x3404,0x3604,0x3804,0x3904,0x4004,0x3904,0x3704,0x3604,0x3204,0x3404, + 0x3604,0x3704,0x3704,0x3904,0x3B04,0x4004,0x4004,0x4004,0x4004,0x4204, + 0x4204,0x4204,0x4204,0x3204,0x3204,0x3204,0x3204,0x3704,0x3204,0x3404, + 0x3604,0x3704,0x3704,0x3904,0x3904,0x3B04,0x3604,0x3704,0x3904,0x3B04, + 0x3B04,0x4004,0x4004,0x4204,0x4204,0x4304,0x4304,0x4408,0x8008,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3001,0x3210,0x2708,0x8018,0x3001,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001,0x3001, + 0x3001,0x3001,0x3001,0x3001,0x3210,0x2708,0x8018,0x3008,0x8008,0x3208, + 0x8008,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, + 0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, + 0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704,0x2704, + 0x2704,0x2704,0x2704,0x2704,0x2B04,0x3204,0x3704,0x3B04,0x3704,0x4204, + 0x3B04,0x3708,0x2706,0x2702,0x2708,0x8008, + 0x0000 +}; + + + +const unsigned long FreqTab [12] = { + 6848,6464,6100,5760,5428,5124,4836,4564,4308,4068,3844,3628, // FIXME +}; + +typedef struct { + unsigned char DoneMask; /* Set this if we're done */ + unsigned char Trigger; /* Trigger value */ + unsigned char Ticks; /* Ticks for this tone */ + unsigned short Freq; /* Actual frequency value */ + int SoftEnv; + const unsigned* Data; /* Pointer to data */ + int DecVal; +} VoiceCtrl; + +/* Control structs for all three voices */ +static VoiceCtrl V1 = { + 0x01, 0x11, 0, 0, 0, Voice1, 0, +}; +static VoiceCtrl V2 = { + 0x02, 0x41, 0, 0, 0, Voice2, 0, +}; +static VoiceCtrl V3 = { + 0x04, 0x11, 0, 0, 0, Voice3, 0, +}; + +/* Pointers to the structs for easy reference */ +static VoiceCtrl* V [3] = { + &V1, &V2, &V3 +}; + +/* Screen dimensions */ +static unsigned char XSize, YSize; + +/* Variable that contains the time of the next clock tick to play a note */ +static unsigned char NextClock; + +/* Start- and runtime */ +static clock_t StartTime; + +/* Number of ticks for each tone */ +#define TICKS_PER_TONE 10 + +/* Done flag. Contains one bit for each voice. Will contain 0x07 if all +** voices have finished playing. +*/ +static unsigned char Done; + +# define outb(addr,val) (*(addr)) = (val) +# define outw(addr,val) (*(addr)) = (val) + +unsigned char I, N, Offs; +unsigned char Tone; +unsigned char Octave; +unsigned Val; + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + +static void MakeTeeLine (unsigned char Y) +/* Make a divider line */ +{ + cputcxy (0, Y, CH_LTEE); + chline (XSize - 2); + cputc (CH_RTEE); +} + +static void MakeNiceScreen (void) +/* Make a nice screen */ +{ + typedef struct { + unsigned char Y; + char* Msg; + } TextDesc; + static TextDesc Text [] = { + /*12345678901234567890*/ + { 1, "Wolfgang A. Mozart" }, + { 2, "Eine kleine" }, + { 3, "Nachtmusik" }, + { 4, "(KV 525)" }, + { 6, "Ported to Gamate" }, + { 7, "Groepaz / Hitmen"}, + }; + + register const TextDesc* T; + unsigned char I; + unsigned char X; + + /* Clear the screen hide the cursor, set colors */ + textcolor (COLOR_BLACK); + bgcolor (COLOR_WHITE); + clrscr (); + cursor (0); + + /* Top line */ + cputcxy (0, 0, CH_ULCORNER); + chline (XSize - 2); + cputc (CH_URCORNER); + + /* Left line */ + cvlinexy (0, 1, YSize - 2); + + /* Bottom line */ + cputc (CH_LLCORNER); + chline (XSize - 2); + cputc (CH_LRCORNER); + + /* Right line */ + cvlinexy (XSize - 1, 1, YSize - 2); + + /* Several divider lines */ + MakeTeeLine (5); + MakeTeeLine (8); + + /* Write something into the frame */ + for (I = 0, T = Text; I < sizeof (Text) / sizeof (Text [0]); ++I) { + X = (XSize - strlen (T->Msg)) / 2; + cputsxy (X, T->Y, T->Msg); + ++T; + } +} + +void UpdateScreen(void) +{ + register VoiceCtrl* VC; + /* Play all three voices */ + for (I = 0; I < 3; ++I) { + /* Get a pointer to this voice */ + VC = V [I]; + Offs = (I * 6) + 1; + textcolor(1); + gotoxy(Offs, 9); cprintf("%02x", VC->SoftEnv); + textcolor(COLOR_BLACK); + for (N = 0; N < 0x8; ++N) { + gotoxy(Offs, 10 + N); + cputc((VC->SoftEnv >> 5) >= (N ^ 0x7) ? '#' : '.' ); + } + } +} + +void DoEffects(void) +{ + register VoiceCtrl* VC; + /* Play all three voices */ + for (I = 0; I < 3; ++I) { + /* Get a pointer to this voice */ + VC = V [I]; + /* do soft envelope */ + if (VC->DecVal < 0) { + if ((VC->SoftEnv + VC->DecVal) > 0) { + VC->SoftEnv += VC->DecVal; + } else { + VC->SoftEnv = 0; + } + } else if (VC->DecVal > 0) { + if ((VC->SoftEnv + VC->DecVal) < 0xff) { + VC->SoftEnv += VC->DecVal; + } else { + VC->SoftEnv = 0xff; + } + } + outb ((unsigned char*)(AUDIO_BASE + 8 + I), VC->SoftEnv); // volume + } +} + +static void TimeSync (void) +/* Sync the time for the next tone */ +{ + static unsigned char Clock, LastClock; + + while ((Clock = clock ()) < NextClock) { + while ((Clock = clock ()) == LastClock) {}; + LastClock = Clock; + + DoEffects(); + } + UpdateScreen(); + NextClock = Clock + TICKS_PER_TONE; +} + +unsigned char getbits(void) +{ + return rand() >> 8; +} + +const unsigned char Tone1[12] = { + 'c','c','d','d','e','f','f','g','g','a','a','h' +}; +const unsigned char Tone2[12] = { + '-','#','-','#','-','-','#','-','#','-','#','-' +}; + +int main (void) +{ + register VoiceCtrl* VC; + /* Get the screen dimensions */ + screensize (&XSize, &YSize); + + /* Make a nice screen */ + MakeNiceScreen (); + + /* init the sound */ + memset((unsigned char*)(AUDIO_BASE), 0, 8); + outb ((unsigned char*)(AUDIO_BASE + 7), 0x3f); + outw ((unsigned char*)(AUDIO_BASE + 12), 0xff); // env delay + outb ((unsigned char*)(AUDIO_BASE + 13), 0x13); // env ctrl + + /* Sync the clock */ + NextClock = StartTime = clock (); + NextClock += TICKS_PER_TONE; + + /* Play each voice until all three are done */ + while (Done != 0x07) { +#if 0 + /* Display the time in the lower left corner */ + DisplayTime (); +#endif + /* Wait for the next run */ + TimeSync (); + + /* Play all three voices */ + for (I = 0; I < 3; ++I) { + + /* Get a pointer to this voice */ + VC = V [I]; + + /* Is this voice done? */ + if (Done & VC->DoneMask) { + /* Voice already done */ + continue; + } + + Offs = (I * 6) + 2; + + /* Do we have any more ticks to play? */ + if (VC->Ticks == 0) { + /* We need new data */ + if ((Val = *VC->Data) == 0) { + /* End of data. Mark the voice as done */ + Done |= VC->DoneMask; + continue; + } + ++VC->Data; + + /* Get the ticks from the data */ + VC->Ticks = (Val & 0x7F) - 1; + + /* Check if this is a tone or a pause */ + if (Val & 0x8000) { + /* This is a pause. */ + gotoxy(Offs + 1, 9); cprintf("---"); + VC->DecVal = -17 - (getbits() & 0x07); + } else { + /* This is a tone. Extract the attributes. */ + Tone = (Val >> 8) & 0x0F; + Octave = ((Val >> 12) & 0x07) ^ 0x07; + /* Calculate the frequency */ + VC->Freq = FreqTab [Tone] >> Octave; + /* Set the frequency */ + + /* ~ 0xb00 is max value (lowest note) */ + VC->Freq >>= 1; + VC->Freq &= 0x0fff; + + outb ((unsigned char*)(AUDIO_BASE + (I << 1) + 1), VC->Freq >> 8); + outb ((unsigned char*)(AUDIO_BASE + (I << 1)), VC->Freq & 0xff); + /* Start the tone */ + VC->DecVal = 13 + (getbits() & 0x07); + gotoxy(Offs + 1, 9); cprintf("%c%c%d", Tone1[Tone], Tone2[Tone], Octave); + } + } else { + /* Decrement the ticks. If this is the last tick of a tone, + ** reset bit 0 of the trigger value and write it back to the + ** SID to start the release phase. + */ + if (--(VC->Ticks) == 0) { + VC->DecVal = -11 - (getbits() & 0x07); + gotoxy(Offs + 1, 9); cprintf("---"); + } + } + + gotoxy(Offs, 10); cprintf("%04x", VC->Freq); + } + } + + /* Done */ + return 0; +} + + + From 5bf8523dcd61f140e7ed5921e529a1b75c9b471b Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Mon, 30 Nov 2015 19:48:10 +0100 Subject: [PATCH 13/16] fix hello.c --- samples/hello.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello.c b/samples/hello.c index 78c28af89..385112367 100644 --- a/samples/hello.c +++ b/samples/hello.c @@ -68,7 +68,7 @@ int main (void) gotoxy ((XSize - strlen (Text)) / 2, YSize / 2); cprintf ("%s", Text); -#if defined(__NES__) || defined(__PCE__) +#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) /* Wait for the user to press a button */ joy_install (joy_static_stddrv); From d86397fd7d9e869df6d5e33db88d947cfef56393 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 1 Dec 2015 16:38:00 +0100 Subject: [PATCH 14/16] fix grammar --- include/gamate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gamate.h b/include/gamate.h index b7c2fef7a..82bca08b1 100644 --- a/include/gamate.h +++ b/include/gamate.h @@ -144,7 +144,7 @@ /* 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 + these are not used elsewhere in the bios and can be (re)set as needed by the user. */ #define ZP_IRQ_CNT1 0x0e From 7de50b17c7d28baeb354cd0723aa3b8f6daa5100 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Tue, 1 Dec 2015 16:55:02 +0100 Subject: [PATCH 15/16] fix comments --- libsrc/gamate/vga.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libsrc/gamate/vga.inc b/libsrc/gamate/vga.inc index f605258bb..da20dd4aa 100644 --- a/libsrc/gamate/vga.inc +++ b/libsrc/gamate/vga.inc @@ -1,7 +1,8 @@ -; VGA charset for the PC-Engine conio implementation +; VGA charset for the Gamate conio implementation .byte $00, $00, $00, $00, $00, $00, $00, $00 + ; 1 .byte %00000000 .byte %00000000 @@ -11,6 +12,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 + ; 2 .byte %00010000 .byte %00010000 @@ -20,6 +22,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 + ; 3 .byte %00010000 .byte %00010000 @@ -29,6 +32,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 + ; 4 .byte %00000000 .byte %00000000 @@ -38,6 +42,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 + ; 5 .byte %00000000 .byte %00000000 @@ -47,6 +52,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 + ; 6 .byte %00010000 .byte %00010000 @@ -56,6 +62,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 + ; 7 .byte %00010000 .byte %00010000 @@ -65,6 +72,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 + ; 8 .byte %00000000 .byte %00000000 @@ -74,6 +82,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 + ; 9 .byte %00010000 .byte %00010000 @@ -83,6 +92,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 + ; 10 (LF) .byte %00000000 .byte %00000000 @@ -92,6 +102,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 + ; 11 .byte %00010000 .byte %00010000 @@ -101,6 +112,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 + ; 12 .byte %00010000 .byte %00010000 From 5d3e7eeae327aecb704e7bb57ec79a4704350b27 Mon Sep 17 00:00:00 2001 From: mrdudz <mrdudz@users.noreply.github.com> Date: Fri, 25 Dec 2015 00:59:22 +0100 Subject: [PATCH 16/16] tweaked soft env --- testcode/lib/gamate/nachtm.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/testcode/lib/gamate/nachtm.c b/testcode/lib/gamate/nachtm.c index 780e95693..6cf8fe1fd 100644 --- a/testcode/lib/gamate/nachtm.c +++ b/testcode/lib/gamate/nachtm.c @@ -863,7 +863,7 @@ typedef struct { unsigned char Trigger; /* Trigger value */ unsigned char Ticks; /* Ticks for this tone */ unsigned short Freq; /* Actual frequency value */ - int SoftEnv; + unsigned short SoftEnv; const unsigned* Data; /* Pointer to data */ int DecVal; } VoiceCtrl; @@ -985,11 +985,11 @@ void UpdateScreen(void) VC = V [I]; Offs = (I * 6) + 1; textcolor(1); - gotoxy(Offs, 9); cprintf("%02x", VC->SoftEnv); + gotoxy(Offs, 9); cprintf("%02x", VC->SoftEnv >> 8); textcolor(COLOR_BLACK); for (N = 0; N < 0x8; ++N) { gotoxy(Offs, 10 + N); - cputc((VC->SoftEnv >> 5) >= (N ^ 0x7) ? '#' : '.' ); + cputc((VC->SoftEnv >> (8+5)) >= (N ^ 0x7) ? '#' : '.' ); } } } @@ -1002,20 +1002,30 @@ void DoEffects(void) /* Get a pointer to this voice */ VC = V [I]; /* do soft envelope */ + if (VC->DecVal != 0) { if (VC->DecVal < 0) { +// VC->DecVal = - 0x400; if ((VC->SoftEnv + VC->DecVal) > 0) { VC->SoftEnv += VC->DecVal; +// VC->SoftEnv >>= 1; + VC->SoftEnv = (VC->SoftEnv >> 1) + (VC->SoftEnv >> 2); } else { VC->SoftEnv = 0; + VC->DecVal = 0; } } else if (VC->DecVal > 0) { - if ((VC->SoftEnv + VC->DecVal) < 0xff) { + VC->DecVal = 0x800; + if (VC->SoftEnv < (0xffff - VC->DecVal)) { +// VC->SoftEnv += VC->DecVal; VC->SoftEnv += VC->DecVal; } else { - VC->SoftEnv = 0xff; + VC->SoftEnv = 0xffff; + VC->DecVal = -VC->DecVal; } } - outb ((unsigned char*)(AUDIO_BASE + 8 + I), VC->SoftEnv); // volume + } +// outb ((unsigned char*)(AUDIO_BASE + 8 + I), (VC->SoftEnv & 0xf0 ) | 0x0f); // volume + outb ((unsigned char*)(AUDIO_BASE + 8 + I),(VC->SoftEnv >> 8)); // volume } } @@ -1105,7 +1115,7 @@ int main (void) if (Val & 0x8000) { /* This is a pause. */ gotoxy(Offs + 1, 9); cprintf("---"); - VC->DecVal = -17 - (getbits() & 0x07); + VC->DecVal = -11 - (getbits() & 0x07); } else { /* This is a tone. Extract the attributes. */ Tone = (Val >> 8) & 0x0F; @@ -1121,7 +1131,7 @@ int main (void) outb ((unsigned char*)(AUDIO_BASE + (I << 1) + 1), VC->Freq >> 8); outb ((unsigned char*)(AUDIO_BASE + (I << 1)), VC->Freq & 0xff); /* Start the tone */ - VC->DecVal = 13 + (getbits() & 0x07); + VC->DecVal = 1 + (getbits() & 0x07); gotoxy(Offs + 1, 9); cprintf("%c%c%d", Tone1[Tone], Tone2[Tone], Octave); } } else {