diff --git a/.gitignore b/.gitignore
index bbf313b..e36ddec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,6 @@
# Debug files
*.dSYM/
+
+/build/*
+/output.txt
\ No newline at end of file
diff --git a/MAKE2bin.BAT b/MAKE2bin.BAT
new file mode 100644
index 0000000..3d3b459
--- /dev/null
+++ b/MAKE2bin.BAT
@@ -0,0 +1,2 @@
+hex2bin -s 4000 -l 8000 -e ROM build\tarp.ihx
+pause
diff --git a/MAKEFILE.BAT b/MAKEFILE.BAT
new file mode 100644
index 0000000..92f7a67
--- /dev/null
+++ b/MAKEFILE.BAT
@@ -0,0 +1,3 @@
+sdcc -mz80 -o build\ --code-loc 0x4020 --data-loc 0xC000 --use-stdout --no-std-crt0 libs\crt0msx.16k.4000.rel libs\functions.rel libs\VDP_TMS9918_BIOS.rel src\tarp.c
+hex2bin -s 0 -l 8000 build\tarp.ihx
+pause
diff --git a/TARP.xprj b/TARP.xprj
new file mode 100644
index 0000000..3accdcb
--- /dev/null
+++ b/TARP.xprj
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ TARP
+ build
+ dist
+ include
+ REL
+ 1
+ 4020
+ C000
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dist/tarp.ROM b/dist/tarp.ROM
new file mode 100644
index 0000000..3e20e38
Binary files /dev/null and b/dist/tarp.ROM differ
diff --git a/include/VDP_TMS9918.h b/include/VDP_TMS9918.h
new file mode 100644
index 0000000..fce1bd4
--- /dev/null
+++ b/include/VDP_TMS9918.h
@@ -0,0 +1,178 @@
+/* ========================================================================== */
+/* */
+/* VDP_TMS9918.h */
+/* */
+/* Description */
+/* Opensource library for acces to VDP TMS9918 */
+/* ========================================================================== */
+#ifndef __VDP_TMS9918_H__
+#define __VDP_TMS9918_H__
+
+#include "newTypes.h"
+
+
+// screen modes - modos de pantalla
+#define TXT40 0x00 // text mode (sc0)
+#define TXT32 0x01 // graphics 1 mode (sc1)
+#define GRAPH1 0x02 // graphics 2 mode (sc2)
+#define GRAPH2 0x03 // multicolor mode (sc3)
+
+// palette color codes by L!T
+#define TRANSPARENT 0
+#define BLACK 1
+#define GREEN 2
+#define LIGHT_GREEN 3
+#define DARK_BLUE 4
+#define LIGHT_BLUE 5
+#define DARK_RED 6
+#define CYAN 7
+#define RED 8
+#define LIGHT_RED 9
+#define DARK_YELLOW 10
+#define LIGHT_YELLOW 11
+#define DARK_GREEN 12
+#define MAGENTA 13
+#define GRAY 14
+#define GREY 14
+#define WHITE 15
+
+// direcciones tablas VRAM screen 0 TXT40
+#define BASE0 0x0000 // base 0 name table (0)
+#define BASE2 0x0800 // base 2 character pattern table (2048)
+
+// direcciones tablas VRAM screen 1 TXT32
+#define BASE5 0x1800 // base 5 name table (6144)
+#define BASE6 0x2000 // base 6 color table (8192)
+#define BASE7 0x0000 // base 7 character pattern table (0)
+#define BASE8 0x1B00 // base 8 sprite attribute table (6912)
+#define BASE9 0x3800 // base 9 sprite pattern table (14336)
+
+// direcciones tablas VRAM screen 2 GRAPH1
+#define BASE10 0x1800 // base 10 name table (6144)
+#define BASE11 0x2000 // base 11 color table (8192)
+#define BASE12 0x0000 // base 12 character pattern table (0)
+#define BASE13 0x1B00 // base 13 sprite attribute table (6912)
+#define BASE14 0x3800 // base 14 sprite pattern table (14336)
+
+// direcciones tablas VRAM screen 3 GRAPH2
+#define BASE15 0x0800 // base 15 name table (2048)
+#define BASE17 0x0000 // base 17 character pattern table (0)
+#define BASE18 0x1B00 // base 18 sprite attribute table (6912)
+#define BASE19 0x3800 // base 19 sprite pattern table (14336)
+
+
+/* ===========================================================================
+ screen
+ Function : Sets the display mode of the screen.
+ Input : mode (char) - number of screen mode
+=========================================================================== */
+void screen(char mode);
+
+/* ===========================================================================
+ color
+ Function : Specifies the foreground color, background and area of the edges.
+ Input : ink (char) - number of ink color
+ border (char) - number of border color
+=========================================================================== */
+void color(char ink, char border);
+
+/* ===========================================================================
+ vpoke
+ Function : Writes a byte to the video RAM.
+ Input : address (unsigned int) - memory address
+ value (unsigned char) - value
+ by L!T
+=========================================================================== */
+void vpoke(uint address, byte value);
+
+
+/* ===========================================================================
+ vpeek
+ Function : Reads data from the video RAM.
+ Input : address (unsigned int) - memory address
+ by L!T
+=========================================================================== */
+unsigned char vpeek(uint address);
+
+
+/* ===========================================================================
+ vpoke_block
+ Escribe un bloque de datos en la VRAM.
+ Write a block of data in the VRAM.
+ by Andrear
+=========================================================================== */
+void vpoke_block(uint address, char* block, uint size);
+
+
+/* ===========================================================================
+fillVRAM (FILVRM - BIOS Address : #0056)
+Function : Fill a large area of the VRAM of the same byte.
+ Llena un area de la RAM de video de un mismo byte.
+Input : vaddress (unsigned int) - Start address of VRAM
+ size (unsigned int) - blocklength
+ value (unsigned char) - Value to fill.
+=========================================================================== */
+void fillVRAM (uint vaddress, uint size, byte value);
+
+
+/* ===========================================================================
+LDIRVM
+Address : #005C
+Function : Block transfer from memory to VRAM
+Input : BC - blocklength
+ DE - Start address of VRAM
+ HL - Start address of memory
+=========================================================================== */
+void copy2VRAM(uint address, uint vaddress, uint length);
+
+
+/* ===========================================================================
+LDIRMV
+#0059
+Function : Block transfer from VRAM to memory
+Input : BC - blocklength
+ DE - Start address of memory
+ HL - Start address of VRAM
+=========================================================================== */
+void copyFromVRAM(uint vaddress, uint address, uint length);
+
+
+// ===========================================================================
+// muestra un sprite en la pantalla
+// by Andrear
+// ===========================================================================
+// DEPRECATED
+//void put_sprite(byte number, byte xpos, byte ypos, byte color);
+
+
+/* ===========================================================================
+ setSpriteCol
+
+ by L!T
+=========================================================================== */
+void setSpriteCol(char num, char col);
+
+/* ===========================================================================
+ setSpritePos
+
+ by L!T
+=========================================================================== */
+void setSpritePos(char num, byte x, byte y);
+
+/* ===========================================================================
+ setSpritePat
+
+ by L!T
+=========================================================================== */
+void setSpritePat(char num, char pat);
+
+
+/* ===========================================================================
+ inicializa los sprites en screen2
+ initializes the sprites in Screen2
+ by Andrear
+=========================================================================== */
+void setupSprites(char spritesize, char zoom);
+
+
+#endif
\ No newline at end of file
diff --git a/include/functions.h b/include/functions.h
new file mode 100644
index 0000000..6d088de
--- /dev/null
+++ b/include/functions.h
@@ -0,0 +1,47 @@
+#ifndef __FUNCTIONS_H__
+#define __FUNCTIONS_H__
+
+#include "newTypes.h"
+
+/*
+int x;
+int y;
+byte acel;
+byte speed;
+*/
+
+
+//void joyController(char controller);
+//void mouseController();
+//void joyController(char controller, int *nx, int *ny, byte *nacel, byte *nspeed);
+
+//byte strLength(char * str);
+void vprint(byte posx, byte posy, char* text);
+void vPrintLines(byte posx, byte posy, char* text);
+void vprintLength(byte posx, byte posy, char* text, byte length);
+//void vprintNumber(byte column, byte line, uint aNumber, byte aLength);
+
+byte peek(unsigned int address);
+int peek_word(int address);
+void poke_word(int address,int value);
+void poke(int address, char value);
+void poke_block(int address, char* block, int size);
+
+char joystick(unsigned char n);
+char joytrig(unsigned char n);
+
+byte inkey();
+//void wait_retrace();
+
+void CHKRAM();
+void KILBUF();
+byte SNSMAT(byte line);
+
+//byte getNumTile(byte xPos, byte yPos);
+byte getNumTileByCoordinates(byte xPos, byte yPos);
+//int getAddress(byte column, byte line);
+int getVAddressByPosition(byte column, byte line);
+
+
+
+#endif
\ No newline at end of file
diff --git a/include/newTypes.h b/include/newTypes.h
new file mode 100644
index 0000000..89a3e22
--- /dev/null
+++ b/include/newTypes.h
@@ -0,0 +1,24 @@
+#ifndef __NEWTYPES_H__
+#define __NEWTYPES_H__
+
+// boolean
+typedef enum {false = 0, true = 1} boolean;
+
+// unsigned integer
+#ifndef uint
+typedef unsigned int uint;
+#endif
+
+// unsigned char
+#ifndef byte
+typedef unsigned char byte;
+#endif
+
+// Z80 Wait for interrupt or reset
+//#define HALT __asm halt __endasm
+
+// MSX System Variables
+#define CLIKSW 0xF3DB // 0 disabled / 1 enabled
+
+
+#endif
\ No newline at end of file
diff --git a/libs/VDP_TMS9918.rel b/libs/VDP_TMS9918.rel
new file mode 100644
index 0000000..2cbf6b2
--- /dev/null
+++ b/libs/VDP_TMS9918.rel
@@ -0,0 +1,249 @@
+XL
+H 7 areas 26 global symbols
+M VDP_TMS9918
+O -mz80
+S .__.ABS. Def0000
+A _CODE size 26A flags 0 addr 0
+S _setSpriteCol Def018C
+S _copy2VRAM Def0126
+S _vpoke_block_end Def00F7
+S _copyFromVRAM Def0158
+S _vpoke Def0044
+S _vpeek_start Def0066
+S _setSpritePat Def01F6
+S _fillVRAM_start Def00F7
+S _color_start Def0024
+S _setSpriteCol_start Def018C
+S _copy2VRAM_start Def0126
+S _vpeek_end Def0084
+S _copyFromVRAM_start Def0158
+S _vpoke_start Def0044
+S _fillVRAM_end Def0126
+S _setSpritePat_start Def01F6
+S _color_end Def0044
+S _setSpritePos Def01B6
+S _setSpriteCol_end Def01B6
+S _copy2VRAM_end Def0158
+S _copyFromVRAM_end Def018C
+S _vpoke_end Def0066
+S _setupSprites Def022F
+S _setSpritePat_end Def022F
+S _screen Def0000
+S _setSpritePos_start Def01B6
+S _setupSprites_start Def022F
+S _setSpritePos_end Def01F6
+S _screen_start Def0000
+S _vpoke_block Def0084
+S _setupSprites_end Def026A
+S _screen_end Def0024
+S _vpeek Def0066
+S _vpoke_block_start Def0084
+S _fillVRAM Def00F7
+S _color Def0024
+A _DATA size 1 flags 0 addr 0
+S _t_spritesize Def0000
+A _OVERLAY size 0 flags 0 addr 0
+A _HOME size 0 flags 0 addr 0
+A _GSINIT size 0 flags 0 addr 0
+A _GSFINAL size 0 flags 0 addr 0
+A _CABS size 0 flags 0 addr 0
+T 00 00
+R 00 00 01 00
+T 00 00
+R 00 00 01 00
+T 00 00
+R 00 00 00 00
+T 00 00
+R 00 00 00 00
+T 00 00 DD E5 DD 21 00 00 DD 39 DD E5 FD E5 DD 7E
+R 00 00 00 00
+T 0E 00 04 32 AF FC DD 21 5F 00 FD 2A C0 FC CD
+R 00 00 00 00
+T 1B 00 1C 00 FD E1 DD E1 DD E1 C9
+R 00 00 00 00
+T 24 00
+R 00 00 00 00
+T 24 00
+R 00 00 00 00
+T 24 00
+R 00 00 00 00
+T 24 00 DD E5 DD 21 00 00 DD 39 DD 7E 04 DD 46 05
+R 00 00 00 00
+T 32 00 CB 27 CB 27 CB 27 CB 27 80 D3 99 3E 87 D3
+R 00 00 00 00
+T 40 00 99 DD E1 C9
+R 00 00 00 00
+T 44 00
+R 00 00 00 00
+T 44 00
+R 00 00 00 00
+T 44 00
+R 00 00 00 00
+T 44 00 DD E5 DD 21 00 00 DD 39 F3 DD 6E 04 DD 66
+R 00 00 00 00
+T 52 00 05 F3 7D D3 99 7C C6 40 D3 99 FB DD 7E 06
+R 00 00 00 00
+T 60 00 D3 98 FB DD E1 C9
+R 00 00 00 00
+T 66 00
+R 00 00 00 00
+T 66 00
+R 00 00 00 00
+T 66 00
+R 00 00 00 00
+T 66 00 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T 74 00 7D D3 99 7C C6 40 D3 99 DB 98 26 00 6F DD
+R 00 00 00 00
+T 82 00 E1 C9
+R 00 00 00 00
+T 84 00
+R 00 00 00 00
+T 84 00
+R 00 00 00 00
+T 84 00
+R 00 00 00 00
+T 84 00 DD E5 DD 21 00 00 DD 39 21 FB FF 39 F9 DB
+R 00 00 00 00
+T 92 00 99 DD 7E 06 DD 77 FC DD 7E 07 DD 77 FD DD
+R 00 00 00 00
+T A0 00 5E 04 DD 56 05 DD 7E 08 DD 77 FE DD 7E 09
+R 00 00 00 00
+T AE 00 DD 77 FF
+R 00 00 00 00
+T B1 00
+R 00 00 00 00
+T B1 00 DD 6E FE DD 66 FF DD 6E FE DD 66 FF 2B DD
+R 00 00 00 00
+T BF 00 75 FE DD 74 FF 7D B4 28 2A DD 6E FC DD 66
+R 00 00 00 00
+T CD 00 FD 7E DD 77 FB DD 34 FC 20 03 DD 34 FD
+R 00 00 00 00
+T DA 00
+R 00 00 00 00
+T DA 00 4B 42 13 DD 73 04 DD 72 05 D5 DD 7E FB F5
+R 00 00 00 00
+T E8 00 33 C5 CD 44 00 F1 33 D1 18 BF
+R 00 00 00 00 00 05 00 00
+T F2 00
+R 00 00 00 00
+T F2 00 DD F9 DD E1 C9
+R 00 00 00 00
+T F7 00
+R 00 00 00 00
+T F7 00
+R 00 00 00 00
+T F7 00
+R 00 00 00 00
+T F7 00 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T 05 01 DB 99 F3 7D D3 99 7C C6 40 D3 99 FB DD 5E
+R 00 00 00 00
+T 13 01 06 DD 56 07 DD 7E 08 47
+R 00 00 00 00
+T 1B 01
+R 00 00 00 00
+T 1B 01 78 D3 98 1B 7A B3 20 F8 DD E1 C9
+R 00 00 00 00
+T 26 01
+R 00 00 00 00
+T 26 01
+R 00 00 00 00
+T 26 01
+R 00 00 00 00
+T 26 01 DD E5 DD 21 00 00 DD 39 DD 6E 06 DD 66 07
+R 00 00 00 00
+T 34 01 DB 99 F3 7D D3 99 7C C6 40 D3 99 FB DD 6E
+R 00 00 00 00
+T 42 01 04 DD 66 05 DD 5E 08 DD 56 09 0E 98
+R 00 00 00 00
+T 4E 01
+R 00 00 00 00
+T 4E 01 ED A3 1B 7A B3 20 F9 DD E1 C9
+R 00 00 00 00
+T 58 01
+R 00 00 00 00
+T 58 01
+R 00 00 00 00
+T 58 01
+R 00 00 00 00
+T 58 01 DD E5 DD 21 00 00 DD 39 DD 4E 04 DD 46 05
+R 00 00 00 00
+T 66 01 DD 6E 06 DD 66 07 DD 5E 08 DD 56 09 DB 99
+R 00 00 00 00
+T 74 01 F3 79 D3 99 78 C6 40 D3 99 FB DB 98 0E 98
+R 00 00 00 00
+T 82 01
+R 00 00 00 00
+T 82 01 ED A2 1B 7A B3 20 F9 DD E1 C9
+R 00 00 00 00
+T 8C 01
+R 00 00 00 00
+T 8C 01
+R 00 00 00 00
+T 8C 01
+R 00 00 00 00
+T 8C 01 DD E5 DD 21 00 00 DD 39 DD 4E 05 DD 6E 04
+R 00 00 00 00
+T 9A 01 DD 7E 04 17 9F 67 29 29 7D C6 03 5F 7C CE
+R 00 00 00 00
+T A8 01 1B 57 79 F5 33 D5 CD 44 00 F1 33 DD E1 C9
+R 00 00 00 00 00 09 00 00
+T B6 01
+R 00 00 00 00
+T B6 01
+R 00 00 00 00
+T B6 01
+R 00 00 00 00
+T B6 01 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 7E 04
+R 00 00 00 00
+T C4 01 17 9F 4D 47 CB 21 CB 10 CB 21 CB 10 21
+R 00 00 00 00
+T D1 01 00 1B 09 EB C5 DD 7E 06 F5 33 D5 CD 44 00
+R 00 00 00 00 00 0E 00 00
+T DF 01 F1 33 C1 21 01 1B 09 4D 44 DD 7E 05 F5 33
+R 00 00 00 00
+T ED 01 C5 CD 44 00 F1 33 DD E1 C9
+R 00 00 00 00 00 04 00 00
+T F6 01
+R 00 00 00 00
+T F6 01
+R 00 00 00 00
+T F6 01
+R 00 00 00 00
+T F6 01 DD E5 DD 21 00 00 DD 39 3A 00 00 D6 01 20
+R 00 00 00 00 00 0B 01 00
+T 04 02 08 DD CB 05 26 DD CB 05 26
+R 00 00 00 00
+T 0D 02
+R 00 00 00 00
+T 0D 02 DD 4E 05 DD 6E 04 DD 7E 04 17 9F 67 29 29
+R 00 00 00 00
+T 1B 02 7D C6 02 5F 7C CE 1B 57 79 F5 33 D5 CD
+R 00 00 00 00
+T 28 02 44 00 F1 33 DD E1 C9
+R 00 00 00 00 00 02 00 00
+T 2F 02
+R 00 00 00 00
+T 2F 02
+R 00 00 00 00
+T 2F 02
+R 00 00 00 00
+T 2F 02 DD E5 DD 21 00 00 DD 39 DD 7E 04 FD 21
+R 00 00 00 00
+T 3C 02 00 00 FD 77 00 DB 99 06 00 DD 7E 04 E6 0F
+R 00 00 00 00 00 02 01 00
+T 4A 02 FE 08 28 02 CB C8
+R 00 00 00 00
+T 50 02
+R 00 00 00 00
+T 50 02 DD 7E 05 FE 00 28 02 CB C0
+R 00 00 00 00
+T 59 02
+R 00 00 00 00
+T 59 02 21 E0 F3 7E E6 FC B0 77 D3 99 3E 81 D3 99
+R 00 00 00 00
+T 67 02 DD E1 C9
+R 00 00 00 00
+T 6A 02
+R 00 00 00 00
diff --git a/libs/VDP_TMS9918_BIOS.rel b/libs/VDP_TMS9918_BIOS.rel
new file mode 100644
index 0000000..bfbf10b
--- /dev/null
+++ b/libs/VDP_TMS9918_BIOS.rel
@@ -0,0 +1,229 @@
+XL
+H 7 areas 26 global symbols
+M VDP_TMS9918_BIOS
+O -mz80
+S .__.ABS. Def0000
+A _CODE size 204 flags 0 addr 0
+S _setSpriteCol Def0128
+S _copy2VRAM Def00E8
+S _vpoke_block_end Def00CB
+S _copyFromVRAM Def0108
+S _vpoke Def002C
+S _vpeek_start Def0043
+S _setSpritePat Def0192
+S _fillVRAM_start Def00CB
+S _color_start Def0011
+S _setSpriteCol_start Def0128
+S _copy2VRAM_start Def00E8
+S _vpeek_end Def005A
+S _copyFromVRAM_start Def0108
+S _vpoke_start Def002C
+S _fillVRAM_end Def00E8
+S _setSpritePat_start Def0192
+S _color_end Def002C
+S _setSpritePos Def0152
+S _setSpriteCol_end Def0152
+S _copy2VRAM_end Def0108
+S _copyFromVRAM_end Def0128
+S _vpoke_end Def0043
+S _setupSprites Def01CB
+S _setSpritePat_end Def01CB
+S _screen Def0000
+S _setSpritePos_start Def0152
+S _setupSprites_start Def01CB
+S _setSpritePos_end Def0192
+S _screen_start Def0000
+S _vpoke_block Def005A
+S _setupSprites_end Def0204
+S _screen_end Def0011
+S _vpeek Def0043
+S _vpoke_block_start Def005A
+S _fillVRAM Def00CB
+S _color Def0011
+A _DATA size 1 flags 0 addr 0
+S _t_spritesize Def0000
+A _OVERLAY size 0 flags 0 addr 0
+A _HOME size 0 flags 0 addr 0
+A _GSINIT size 0 flags 0 addr 0
+A _GSFINAL size 0 flags 0 addr 0
+A _CABS size 0 flags 0 addr 0
+T 00 00
+R 00 00 01 00
+T 00 00
+R 00 00 01 00
+T 00 00
+R 00 00 00 00
+T 00 00
+R 00 00 00 00
+T 00 00 DD E5 DD 21 00 00 DD 39 DD 7E 04 CD 5F 00
+R 00 00 00 00
+T 0E 00 DD E1 C9
+R 00 00 00 00
+T 11 00
+R 00 00 00 00
+T 11 00
+R 00 00 00 00
+T 11 00
+R 00 00 00 00
+T 11 00 DD E5 DD 21 00 00 DD 39 21 E9 F3 DD 7E 04
+R 00 00 00 00
+T 1F 00 77 23 23 DD 7E 05 77 CD 62 00 DD E1 C9
+R 00 00 00 00
+T 2C 00
+R 00 00 00 00
+T 2C 00
+R 00 00 00 00
+T 2C 00
+R 00 00 00 00
+T 2C 00 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T 3A 00 DD 7E 06 CD 4D 00 DD E1 C9
+R 00 00 00 00
+T 43 00
+R 00 00 00 00
+T 43 00
+R 00 00 00 00
+T 43 00
+R 00 00 00 00
+T 43 00 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T 51 00 CD 4A 00 26 00 6F DD E1 C9
+R 00 00 00 00
+T 5A 00
+R 00 00 00 00
+T 5A 00
+R 00 00 00 00
+T 5A 00
+R 00 00 00 00
+T 5A 00 DD E5 DD 21 00 00 DD 39 21 FB FF 39 F9 DD
+R 00 00 00 00
+T 68 00 7E 06 DD 77 FC DD 7E 07 DD 77 FD DD 5E 04
+R 00 00 00 00
+T 76 00 DD 56 05 DD 7E 08 DD 77 FE DD 7E 09 DD 77
+R 00 00 00 00
+T 84 00 FF
+R 00 00 00 00
+T 85 00
+R 00 00 00 00
+T 85 00 DD 6E FE DD 66 FF DD 6E FE DD 66 FF 2B DD
+R 00 00 00 00
+T 93 00 75 FE DD 74 FF 7D B4 28 2A DD 6E FC DD 66
+R 00 00 00 00
+T A1 00 FD 7E DD 77 FB DD 34 FC 20 03 DD 34 FD
+R 00 00 00 00
+T AE 00
+R 00 00 00 00
+T AE 00 4B 42 13 DD 73 04 DD 72 05 D5 DD 7E FB F5
+R 00 00 00 00
+T BC 00 33 C5 CD 2C 00 F1 33 D1 18 BF
+R 00 00 00 00 00 05 00 00
+T C6 00
+R 00 00 00 00
+T C6 00 DD F9 DD E1 C9
+R 00 00 00 00
+T CB 00
+R 00 00 00 00
+T CB 00
+R 00 00 00 00
+T CB 00
+R 00 00 00 00
+T CB 00 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T D9 00 DD 4E 06 DD 46 07 DD 7E 08 CD 56 00 DD E1
+R 00 00 00 00
+T E7 00 C9
+R 00 00 00 00
+T E8 00
+R 00 00 00 00
+T E8 00
+R 00 00 00 00
+T E8 00
+R 00 00 00 00
+T E8 00 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T F6 00 DD 5E 06 DD 56 07 DD 4E 08 DD 46 09 CD
+R 00 00 00 00
+T 03 01 5C 00 DD E1 C9
+R 00 00 00 00
+T 08 01
+R 00 00 00 00
+T 08 01
+R 00 00 00 00
+T 08 01
+R 00 00 00 00
+T 08 01 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T 16 01 DD 5E 06 DD 56 07 DD 4E 08 DD 46 09 CD
+R 00 00 00 00
+T 23 01 59 00 DD E1 C9
+R 00 00 00 00
+T 28 01
+R 00 00 00 00
+T 28 01
+R 00 00 00 00
+T 28 01
+R 00 00 00 00
+T 28 01 DD E5 DD 21 00 00 DD 39 DD 4E 05 DD 6E 04
+R 00 00 00 00
+T 36 01 DD 7E 04 17 9F 67 29 29 7D C6 03 5F 7C CE
+R 00 00 00 00
+T 44 01 1B 57 79 F5 33 D5 CD 2C 00 F1 33 DD E1 C9
+R 00 00 00 00 00 09 00 00
+T 52 01
+R 00 00 00 00
+T 52 01
+R 00 00 00 00
+T 52 01
+R 00 00 00 00
+T 52 01 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 7E 04
+R 00 00 00 00
+T 60 01 17 9F 4D 47 CB 21 CB 10 CB 21 CB 10 21
+R 00 00 00 00
+T 6D 01 00 1B 09 EB C5 DD 7E 06 F5 33 D5 CD 2C 00
+R 00 00 00 00 00 0E 00 00
+T 7B 01 F1 33 C1 21 01 1B 09 4D 44 DD 7E 05 F5 33
+R 00 00 00 00
+T 89 01 C5 CD 2C 00 F1 33 DD E1 C9
+R 00 00 00 00 00 04 00 00
+T 92 01
+R 00 00 00 00
+T 92 01
+R 00 00 00 00
+T 92 01
+R 00 00 00 00
+T 92 01 DD E5 DD 21 00 00 DD 39 3A 00 00 D6 01 20
+R 00 00 00 00 00 0B 01 00
+T A0 01 08 DD CB 05 26 DD CB 05 26
+R 00 00 00 00
+T A9 01
+R 00 00 00 00
+T A9 01 DD 4E 05 DD 6E 04 DD 7E 04 17 9F 67 29 29
+R 00 00 00 00
+T B7 01 7D C6 02 5F 7C CE 1B 57 79 F5 33 D5 CD
+R 00 00 00 00
+T C4 01 2C 00 F1 33 DD E1 C9
+R 00 00 00 00 00 02 00 00
+T CB 01
+R 00 00 00 00
+T CB 01
+R 00 00 00 00
+T CB 01
+R 00 00 00 00
+T CB 01 DD E5 DD 21 00 00 DD 39 DD 7E 04 FD 21
+R 00 00 00 00
+T D8 01 00 00 FD 77 00 06 00 DD 7E 04 E6 0F FE 08
+R 00 00 00 00 00 02 01 00
+T E6 01 28 02 CB C8
+R 00 00 00 00
+T EA 01
+R 00 00 00 00
+T EA 01 DD 7E 05 FE 00 28 02 CB C0
+R 00 00 00 00
+T F3 01
+R 00 00 00 00
+T F3 01 21 E0 F3 7E E6 FC B0 77 CD 7E 00 CD 69 00
+R 00 00 00 00
+T 01 02 DD E1 C9
+R 00 00 00 00
+T 04 02
+R 00 00 00 00
diff --git a/libs/crt0msx.16k.4000.rel b/libs/crt0msx.16k.4000.rel
new file mode 100644
index 0000000..adee0e9
--- /dev/null
+++ b/libs/crt0msx.16k.4000.rel
@@ -0,0 +1,13 @@
+XL
+H 5 areas 2 global symbols
+S _main Ref0000
+S .__.ABS. Def0000
+A _CODE size 0 flags 0 addr 0
+A _HEADER size 0 flags 8 addr 0
+A _HEADER0 size 1A flags 8 addr 4000
+A _DATA size 0 flags 0 addr 0
+A _BSS size 0 flags 0 addr 0
+T 00 40 41 42 10 40 00 00 00 00 00 00 00 00 00 00
+R 00 00 02 00 00 04 02 00
+T 0E 40 00 00 ED 7B 4A FC CD 00 00 CD 00 00
+R 00 00 02 00 02 09 00 00
diff --git a/libs/functions.rel b/libs/functions.rel
new file mode 100644
index 0000000..b87e143
--- /dev/null
+++ b/libs/functions.rel
@@ -0,0 +1,326 @@
+XL
+H 7 areas 33 global symbols
+M functions
+O -mz80
+S _vpoke Ref0000
+S _vpeek Ref0000
+S .__.ABS. Def0000
+A _CODE size 2E7 flags 0 addr 0
+S _SNSMAT_start Def027E
+S _vprint Def0000
+S _peek Def0168
+S _vprintLength Def00FE
+S _poke_block_start Def01DA
+S _SNSMAT_end Def0292
+S _getVAddressByPosition Def02C6
+S _inkey_start Def0161
+S _poke_block_end Def0250
+S _poke Def01A9
+S _vprint_start Def0000
+S _joystick Def0250
+S _peek_start Def0168
+S _vprintLength_start Def00FE
+S _getNumTileByCoordinates Def0292
+S _inkey_end Def0168
+S _CHKRAM Def0276
+S _getVAddressByPosition_start Def02C6
+S _vprint_end Def0057
+S _peek_end Def017D
+S _vprintLength_end Def0161
+S _poke_start Def01A9
+S _joystick_start Def0250
+S _KILBUF Def027A
+S _vPrintLines Def0057
+S _peek_word Def017D
+S _getNumTileByCoordinates_start Def0292
+S _getVAddressByPosition_end Def02E7
+S _CHKRAM_start Def0276
+S _poke_end Def01BE
+S _joystick_end Def0262
+S _joytrig Def0262
+S _getNumTileByCoordinates_end Def02C6
+S _KILBUF_start Def027A
+S _poke_word Def01BE
+S _vPrintLines_start Def0057
+S _CHKRAM_end Def027A
+S _peek_word_start Def017D
+S _KILBUF_end Def027E
+S _vPrintLines_end Def00FE
+S _joytrig_start Def0262
+S _peek_word_end Def01A9
+S _SNSMAT Def027E
+S _poke_word_start Def01BE
+S _poke_block Def01DA
+S _joytrig_end Def0276
+S _poke_word_end Def01DA
+S _inkey Def0161
+A _DATA size 0 flags 0 addr 0
+A _OVERLAY size 0 flags 0 addr 0
+A _HOME size 0 flags 0 addr 0
+A _GSINIT size 0 flags 0 addr 0
+A _GSFINAL size 0 flags 0 addr 0
+A _CABS size 0 flags 0 addr 0
+T 00 00
+R 00 00 00 00
+T 00 00
+R 00 00 00 00
+T 00 00 DD E5 DD 21 00 00 DD 39 F5 3B DD 6E 05 26
+R 00 00 00 00
+T 0E 00 00 29 29 29 29 29 7D 4F 7C C6 18 47 DD 6E
+R 00 00 00 00
+T 1C 00 04 26 00 09 DD 4E 06 DD 46 07 DD 75 FE DD
+R 00 00 00 00
+T 2A 00 74 FF
+R 00 00 00 00
+T 2C 00
+R 00 00 00 00
+T 2C 00 0A 6F B7 28 21 DD 75 FD 03 DD 5E FE DD 56
+R 00 00 00 00
+T 3A 00 FF DD 34 FE 20 03 DD 34 FF
+R 00 00 00 00
+T 43 00
+R 00 00 00 00
+T 43 00 C5 DD 7E FD F5 33 D5 CD 00 00 F1 33 C1 18
+R 00 00 00 00 02 0A 00 00
+T 51 00 DA
+R 00 00 00 00
+T 52 00
+R 00 00 00 00
+T 52 00 DD F9 DD E1 C9
+R 00 00 00 00
+T 57 00
+R 00 00 00 00
+T 57 00
+R 00 00 00 00
+T 57 00
+R 00 00 00 00
+T 57 00 DD E5 DD 21 00 00 DD 39 21 F9 FF 39 F9 DD
+R 00 00 00 00
+T 65 00 6E 05 26 00 29 29 29 29 29 7D 4F 7C C6 18
+R 00 00 00 00
+T 73 00 47 DD 7E 04 DD 77 F9 DD 36 FA 00 79 DD 86
+R 00 00 00 00
+T 81 00 F9 4F 78 DD 8E FA 47 DD 71 FE DD 70 FF DD
+R 00 00 00 00
+T 8F 00 7E 06 DD 77 FC DD 7E 07 DD 77 FD DD 7E 05
+R 00 00 00 00
+T 9D 00 DD 77 FB
+R 00 00 00 00
+T A0 00
+R 00 00 00 00
+T A0 00 DD 6E FC DD 66 FD 6E AF B5 CA F9 00 7D DD
+R 00 00 00 00 00 0C 00 00
+T AE 00 34 FC 20 03 DD 34 FD
+R 00 00 00 00
+T B5 00
+R 00 00 00 00
+T B5 00 4F D6 0A 20 25 DD 34 FB DD 6E FB 26 00 29
+R 00 00 00 00
+T C3 00 29 29 29 29 7D 47 7C C6 18 5F 78 DD 86 F9
+R 00 00 00 00
+T D1 00 47 7B DD 8E FA 5F DD 70 FE DD 73 FF 18 C1
+R 00 00 00 00
+T DF 00
+R 00 00 00 00
+T DF 00 DD 5E FE DD 56 FF DD 34 FE 20 03 DD 34 FF
+R 00 00 00 00
+T ED 00
+R 00 00 00 00
+T ED 00 79 F5 33 D5 CD 00 00 F1 33 C3 A0 00
+R 00 00 00 00 02 07 00 00 00 0C 00 00
+T F9 00
+R 00 00 00 00
+T F9 00 DD F9 DD E1 C9
+R 00 00 00 00
+T FE 00
+R 00 00 00 00
+T FE 00
+R 00 00 00 00
+T FE 00
+R 00 00 00 00
+T FE 00 DD E5 DD 21 00 00 DD 39 F5 F5 DD 6E 05 26
+R 00 00 00 00
+T 0C 01 00 29 29 29 29 29 7D 4F 7C C6 18 47 DD 6E
+R 00 00 00 00
+T 1A 01 04 26 00 09 DD 4E 06 DD 46 07 DD 75 FD DD
+R 00 00 00 00
+T 28 01 74 FE DD 7E 08 DD 77 FF
+R 00 00 00 00
+T 30 01
+R 00 00 00 00
+T 30 01 DD 6E FF DD 35 FF AF B5 28 22 0A DD 77 FC
+R 00 00 00 00
+T 3E 01 03 DD 5E FD DD 56 FE DD 34 FD 20 03 DD 34
+R 00 00 00 00
+T 4C 01 FE
+R 00 00 00 00
+T 4D 01
+R 00 00 00 00
+T 4D 01 C5 DD 7E FC F5 33 D5 CD 00 00 F1 33 C1 18
+R 00 00 00 00 02 0A 00 00
+T 5B 01 D4
+R 00 00 00 00
+T 5C 01
+R 00 00 00 00
+T 5C 01 DD F9 DD E1 C9
+R 00 00 00 00
+T 61 01
+R 00 00 00 00
+T 61 01
+R 00 00 00 00
+T 61 01
+R 00 00 00 00
+T 61 01 CD 9F 00 26 00 6F C9
+R 00 00 00 00
+T 68 01
+R 00 00 00 00
+T 68 01
+R 00 00 00 00
+T 68 01
+R 00 00 00 00
+T 68 01 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T 76 01 7E 26 00 6F DD E1 C9
+R 00 00 00 00
+T 7D 01
+R 00 00 00 00
+T 7D 01
+R 00 00 00 00
+T 7D 01
+R 00 00 00 00
+T 7D 01 DD E5 DD 21 00 00 DD 39 DD 4E 04 DD 46 05
+R 00 00 00 00
+T 8B 01 C5 C5 CD 68 01 F1 C1 5D 16 00 03 D5 C5 CD
+R 00 00 00 00 00 05 00 00
+T 99 01 68 01 F1 D1 65 2E 00 7B B5 6F 7A B4 67 DD
+R 00 00 00 00 00 02 00 00
+T A7 01 E1 C9
+R 00 00 00 00
+T A9 01
+R 00 00 00 00
+T A9 01
+R 00 00 00 00
+T A9 01
+R 00 00 00 00
+T A9 01 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T B7 01 DD 7E 06 77 DD E1 C9
+R 00 00 00 00
+T BE 01
+R 00 00 00 00
+T BE 01
+R 00 00 00 00
+T BE 01
+R 00 00 00 00
+T BE 01 DD E5 DD 21 00 00 DD 39 DD 6E 04 DD 66 05
+R 00 00 00 00
+T CC 01 DD 5E 06 DD 56 07 7B 77 23 7A 77 DD E1 C9
+R 00 00 00 00
+T DA 01
+R 00 00 00 00
+T DA 01
+R 00 00 00 00
+T DA 01
+R 00 00 00 00
+T DA 01 DD E5 DD 21 00 00 DD 39 21 FB FF 39 F9 DD
+R 00 00 00 00
+T E8 01 7E 06 DD 77 FC DD 7E 07 DD 77 FD DD 5E 04
+R 00 00 00 00
+T F6 01 DD 56 05 DD 7E 08 DD 77 FE DD 7E 09 DD 77
+R 00 00 00 00
+T 04 02 FF
+R 00 00 00 00
+T 05 02
+R 00 00 00 00
+T 05 02 DD 6E FE DD 66 FF DD 6E FE DD 66 FF 2B DD
+R 00 00 00 00
+T 13 02 75 FE DD 74 FF 3E 00 95 3E 00 9C F2 4B 02
+R 00 00 00 00 00 0E 00 00
+T 21 02 DD 6E FC DD 66 FD 7E DD 77 FB DD 34 FC 20
+R 00 00 00 00
+T 2F 02 03 DD 34 FD
+R 00 00 00 00
+T 33 02
+R 00 00 00 00
+T 33 02 4B 42 13 DD 73 04 DD 72 05 D5 DD 7E FB F5
+R 00 00 00 00
+T 41 02 33 C5 CD A9 01 F1 33 D1 18 BA
+R 00 00 00 00 00 05 00 00
+T 4B 02
+R 00 00 00 00
+T 4B 02 DD F9 DD E1 C9
+R 00 00 00 00
+T 50 02
+R 00 00 00 00
+T 50 02
+R 00 00 00 00
+T 50 02
+R 00 00 00 00
+T 50 02 DD E5 DD 21 00 00 DD 39 DD 7E 04 CD D5 00
+R 00 00 00 00
+T 5E 02 6F DD E1 C9
+R 00 00 00 00
+T 62 02
+R 00 00 00 00
+T 62 02
+R 00 00 00 00
+T 62 02
+R 00 00 00 00
+T 62 02 DD E5 DD 21 00 00 DD 39 DD 7E 04 CD D8 00
+R 00 00 00 00
+T 70 02 26 00 6F DD E1 C9
+R 00 00 00 00
+T 76 02
+R 00 00 00 00
+T 76 02
+R 00 00 00 00
+T 76 02
+R 00 00 00 00
+T 76 02 CD 00 00 C9
+R 00 00 00 00
+T 7A 02
+R 00 00 00 00
+T 7A 02
+R 00 00 00 00
+T 7A 02
+R 00 00 00 00
+T 7A 02 CD 56 01 C9
+R 00 00 00 00
+T 7E 02
+R 00 00 00 00
+T 7E 02
+R 00 00 00 00
+T 7E 02
+R 00 00 00 00
+T 7E 02 DD E5 DD 21 00 00 DD 39 DD 7E 04 CD 41 01
+R 00 00 00 00
+T 8C 02 26 00 6F DD E1 C9
+R 00 00 00 00
+T 92 02
+R 00 00 00 00
+T 92 02
+R 00 00 00 00
+T 92 02
+R 00 00 00 00
+T 92 02 DD E5 DD 21 00 00 DD 39 DD 7E 05 CB 3F CB
+R 00 00 00 00
+T A0 02 3F CB 3F 6F 26 00 29 29 29 29 29 7D 4F 7C
+R 00 00 00 00
+T AE 02 C6 18 47 DD 7E 04 CB 3F CB 3F CB 3F 6F 26
+R 00 00 00 00
+T BC 02 00 09 E5 CD 00 00 F1 DD E1 C9
+R 00 00 00 00 02 06 01 00
+T C6 02
+R 00 00 00 00
+T C6 02
+R 00 00 00 00
+T C6 02
+R 00 00 00 00
+T C6 02 DD E5 DD 21 00 00 DD 39 DD 6E 05 26 00 29
+R 00 00 00 00
+T D4 02 29 29 29 29 7D 4F 7C C6 18 47 DD 6E 04 26
+R 00 00 00 00
+T E2 02 00 09 DD E1 C9
+R 00 00 00 00
+T E7 02
+R 00 00 00 00
diff --git a/src/tarp.c b/src/tarp.c
new file mode 100644
index 0000000..b976919
--- /dev/null
+++ b/src/tarp.c
@@ -0,0 +1,1926 @@
+/* ========================================================================== */
+/* The Alan Randoms Project v0.9b */
+/* tarp_09.c */
+/* by mvac7/303bcn 2012 */
+/* eXperimental Sound Mini-compo (XSM) */
+/* Description: */
+/* Random music maker */
+/* ========================================================================== */
+
+ // Tareas para una futura version:
+ // 1)usar envolvente por soft para percusion.
+ // 2)Añadir editor de instrumentos.
+ // 3) probar con SCC
+ // crear sistema de envolventes por soft
+
+
+//__sfr __at 0xA8 g_slotPort;
+#include "../include/newTypes.h"
+#include "../include/VDP_TMS9918.h"
+#include "../include/functions.h"
+
+#define HALT __asm halt __endasm
+
+#define SEED 0xE000
+#define PLAY_HARDW 0xE010 //(1B) indica por que chip ha de sonar (0=PSG interno;1=PSG MFR;2=SCC)
+#define PSG_RAM 0xE011 //(12B) buffer regs PSG R0-R10
+
+
+
+
+typedef struct {
+
+ boolean isTone;
+ boolean isNoise;
+ uint Tone;
+ char Noise;
+ char Shape;
+ uint Period;
+
+} INST_PERC;
+
+
+typedef struct {
+
+ boolean isLoop;
+ char ampValues[16];
+ //char length;
+
+} Envelope;
+
+
+void logoScreen();
+void WorkWin();
+
+void setTileset();
+void setSprites();
+void setMainScr();
+//void setInitScr();
+void showLogoScreen();
+
+void setMSX2Palette();
+void setMSX2logoPal();
+
+void showEnv(char value);
+void showSpeaker(uint vaddr, boolean value);
+void switcher(uint vaddr, boolean value);
+
+void genDrumPattern();
+void genTonePattern();
+
+void upNotePattern();
+void downNotePattern();
+int getFreq(byte value);
+
+
+void checkMSX();
+
+byte Rnd(char value);
+
+void play();
+byte sound_get(byte reg);
+void sound_set(byte reg, byte val);
+void setChannel(byte NumChannel, boolean isTone, boolean isNoise);
+
+void vpoke(uint address, byte value);
+void vprint(byte posx, byte posy, char* text);
+void vprintNumber(byte posx, byte posy, uint aNumber, byte aLength);
+void Num2Dec16(int aNumber, char *address);
+
+void fillRAM(uint address, int size, byte value);
+
+
+
+
+
+
+
+
+
+
+
+
+// definicion variables globales <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+const char soft[] = "THE ALAN RANDOMS PROJECT V0.91B BY MVAC7/303BCN";
+
+
+const char enve_data[128]={
+14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,14,
+14,12,10, 8, 6, 4, 2, 1, 0, 1, 2, 4, 6, 8,10,12,
+ 0, 1, 2, 4, 6, 8,10,12,14,12,10, 8, 6, 4, 2, 1,
+14,14,14,14,14,14,14,14, 4, 4, 4, 4, 4, 4, 4, 4,
+ 7, 9,12,13,13,13,11, 8, 5, 2, 0, 0, 0, 1, 4, 6,
+14,13,13,12,11,10, 9, 8, 6, 5, 3, 2, 1, 0, 0, 0,
+14,13,12,11,10, 9, 9, 9, 9, 9, 9, 9, 8, 6, 4, 2
+};
+
+const char enve_loop[8]={false,false,true,true,false,false,false,false};
+
+
+
+const char drumcolor[4]={4,2,8,7};
+
+const uint vaddr_cursor[9]={0x1841,0x1901,0x19A1,0x19C1,0x1A01,0x1A21,0x1A41,0x1A81,0x1AA1};
+
+const byte yvalues[64]={
+ 72,65,59,53,47,41,35,30,26,21,18,15,12,10,8,8,
+ 8,8,9,11,13,16,20,24,28,33,38,44,50,56,62,68,
+ 75,81,87,93,99,105,110,115,119,123,127,130,132,134,135,135,
+ 135,135,133,131,128,125,122,117,113,108,102,96,90,84,78,72
+}; //sin 8,136
+
+
+
+const byte xvalues[64]={
+ 96,96,97,98,101,103,107,110,115,120,125,130,136,142,148,155,
+ 161,167,174,180,186,192,197,202,206,211,214,217,220,222,223,223,
+ 223,223,222,220,217,214,211,206,202,197,192,186,180,174,167,161,
+ 155,148,142,136,130,125,120,115,110,107,103,101,98,97,96,96
+}; //cos 96,224
+
+
+byte VDP_type;
+
+char drum_pattern[16];
+byte tone_pattern[16]; //={46,0,49,0,50,0,51,0,46,0,49,0,50,0,51,0};
+
+Envelope env_list[8];
+
+
+
+void main(void) {
+__asm
+ di
+ ld sp, (#0xFC4A)
+ ei
+__endasm;
+
+ checkMSX();
+
+ //g_slotPort = (g_slotPort & 0xCF) | ((g_slotPort & 0x0C) << 2);
+ color(15,1);
+ screen(2);
+
+
+ poke(CLIKSW,0);
+
+ logoScreen();
+
+
+ fillVRAM(BASE10, 768, 32);
+
+ //FastClsSc2(0x00);
+
+
+ WorkWin();
+}
+
+
+
+
+void logoScreen()
+{
+ int timec = 700;
+
+ setupSprites(1,0);
+
+ showLogoScreen();
+
+ setSpritePos(0,74,58);
+ setSpritePat(0,0);
+ setSpriteCol(0,12);
+
+ setSpritePos(1,73,74);
+ setSpritePat(1,1);
+ setSpriteCol(1,12);
+
+ setSpritePos(2,96,57);
+ setSpritePat(2,2);
+ setSpriteCol(2,12);
+
+ setSpritePos(3,96,73);
+ setSpritePat(3,3);
+ setSpriteCol(3,12);
+
+ if (VDP_type>0) setMSX2logoPal();
+
+ while(timec-->0)
+ {
+ HALT;
+ if((SNSMAT(7)|0xFB)==0xFB) break; // ESC
+ //if(SNSMAT(7)==127) break; // RETURN
+ if(SNSMAT(8)==0xFE) break; // SPACE
+ if (joytrig(1)<0 || joytrig(2)<0) break; //button 1, joy A & B
+
+ }
+
+ return;
+}
+
+
+
+
+void WorkWin()
+{
+ boolean isCasio=false;
+ boolean isTone=false;
+ boolean isDrum=false;
+ boolean isAB=true;
+
+ boolean keyB6semaphore=false;
+ boolean keyB7semaphore=false;
+
+ boolean joybool = false;
+
+
+ //uint t;
+ uint freqA;
+ uint freqB;
+
+
+ char amp;
+ char stone_step=0; //de 31
+ char sdrum_step=31;
+ byte sdrum_size=0;
+ char sdrum_color=15;
+ char variacion=0;
+
+ char B_offset =3;
+
+ char Tempo = 4;
+ char tempoStep =4;
+ char pattern_step=0;
+ char last_step=0;
+
+ char drum_type;
+ char tone_note;
+ char octave=2;
+
+ char env_selected=0;
+ char env_speed=1;
+ byte env_step=0;
+
+ char cursor_pos=0;
+
+ byte i,o;
+ byte conta=0;
+
+ byte keyPressed;
+
+ byte joyval;
+
+ //char pattern[16]={1,0,3,3,0,0,3,3,1,0,3,3,0,0,3,3};
+ //char pattern[16]={1,0,3,0,2,0,2,0,1,0,3,0,2,0,3,0}; //rock1
+
+ INST_PERC Percu_casio[3];
+ INST_PERC Percu_basic[3];
+
+ INST_PERC *tmp_INST;
+
+ setupSprites(1,1); //16x16 zoom
+ setSprites();
+
+ // erase sprites 2 & 3 ???
+ //setSpritePat(2,31);
+ //setSpritePat(3,31);
+
+ setTileset();
+
+ if (VDP_type>0) setMSX2Palette();
+
+ setMainScr();
+
+
+ // Instrumentos percusion - Kit Casio PT1
+ // Kick
+ Percu_casio[0].isTone=true;
+ Percu_casio[0].isNoise=false;
+ Percu_casio[0].Tone=140;
+ Percu_casio[0].Noise=0;
+ Percu_casio[0].Shape=1;
+ Percu_casio[0].Period=800;
+
+ // Snare
+ Percu_casio[1].isTone=false;
+ Percu_casio[1].isNoise=true;
+ Percu_casio[1].Tone=0;
+ Percu_casio[1].Noise=0;
+ Percu_casio[1].Shape=1;
+ Percu_casio[1].Period=1600;
+
+ // Hi
+ Percu_casio[2].isTone=true;
+ Percu_casio[2].isNoise=false;
+ Percu_casio[2].Tone=66;
+ Percu_casio[2].Noise=0;
+ Percu_casio[2].Shape=1;
+ Percu_casio[2].Period=400;
+
+
+ // Instrumentos percusion Kit Basico
+ // Kick
+ Percu_basic[0].isTone=true;
+ Percu_basic[0].isNoise=false;
+ Percu_basic[0].Tone=1700;
+ Percu_basic[0].Noise=0;
+ Percu_basic[0].Shape=1;
+ Percu_basic[0].Period=800;
+
+ // Snare
+ Percu_basic[1].isTone=true;
+ Percu_basic[1].isNoise=true;
+ Percu_basic[1].Tone=1000;
+ Percu_basic[1].Noise=0;
+ Percu_basic[1].Shape=1;
+ Percu_basic[1].Period=1200;
+
+ // Hi
+ Percu_basic[2].isTone=false;
+ Percu_basic[2].isNoise=true;
+ Percu_basic[2].Tone=0;
+ Percu_basic[2].Noise=0;
+ Percu_basic[2].Shape=1;
+ Percu_basic[2].Period=200;
+ // end
+
+ // genera las estructuras de datos de las envolventes
+ for(i=0;i<8;i++)
+ {
+ env_list[i].isLoop = enve_loop[i];
+ for(o=0;o<16;o++)
+ {
+ env_list[i].ampValues[o] = enve_data[conta++];
+ }
+ }
+ // end
+
+
+ // genera los patrones de percusion y tono
+ genDrumPattern();
+ genTonePattern();
+
+
+ poke(PLAY_HARDW,0); //selecciona AY interno
+
+ fillRAM(PSG_RAM,13,0); //borra el area del buffer de registros del PSG
+
+ // activa los canales A y B del AY (registro 7)
+ setChannel(0,true,false);
+ setChannel(1,true,false);
+
+ vprintNumber(8,2, Tempo, 1);
+
+ // muestra los valores de los controles
+ switcher(0x1909,isCasio);
+ switcher(0x19A9,isAB);
+ vprintNumber(6,14, B_offset, 3);
+
+ showEnv(env_selected);
+ vprintNumber(8,17, env_speed, 1);
+ switcher(0x1A49,env_list[env_selected].isLoop);
+
+ vprintNumber(8,20, octave, 1);
+ // end set visual controls values
+
+
+ // posiciona el cursor de seleccion de campo
+ vpoke(vaddr_cursor[cursor_pos],186);
+
+
+ while(1)
+ {
+ HALT;
+ play();
+ if (peek(PSG_RAM+13)>0 && isDrum==true) sound_set(13,peek(PSG_RAM+13)); //lanza envolvente · dispara sonido percusion
+
+ if (tempoStep>=Tempo) //control de tempo por ciclos de Vblank
+ {
+ tempoStep=0;
+
+ // cursor de patron
+ vpoke(0x1AAE+last_step,239); //borra la ultima posicion
+ vpoke(0x1AAE+pattern_step,185); //muestra el cursor
+ last_step = pattern_step;
+ //
+
+
+ // control de la percusion
+ drum_type = drum_pattern[pattern_step];
+ if(drum_type>0)
+ {
+ if(isCasio==true) tmp_INST= &Percu_casio[drum_type-1];
+ else tmp_INST= &Percu_basic[drum_type-1];
+
+ setChannel(2,tmp_INST->isTone,tmp_INST->isNoise);
+ poke(PSG_RAM+4,tmp_INST->Tone & 0xFF);
+ poke(PSG_RAM+5,(tmp_INST->Tone & 0xFF00)/255);
+ poke(PSG_RAM+6,tmp_INST->Noise); //noise
+ poke(PSG_RAM+10,16); //volumen canal C
+ poke(PSG_RAM+11,tmp_INST->Period & 0xFF);
+ poke(PSG_RAM+12,(tmp_INST->Period & 0xFF00)/255);
+ poke(PSG_RAM+13,tmp_INST->Shape); //envelope wave form
+
+ sdrum_size=7;
+ sdrum_color=drumcolor[drum_type];
+
+ }else{
+ // es un silencio
+ poke(PSG_RAM+10,0); //volumen canal C
+ //sdrum_size=0;
+ }
+
+
+ // control del intrumento de acompañamiento
+ tone_note = tone_pattern[pattern_step];
+ if(tone_note>0)
+ {
+ freqA = getFreq(tone_note+(octave*12)); //+ variacion;
+ freqB = freqA + B_offset;
+ //vprintNumber(20,0, tone_note, 3); // TEST ##########################
+ //vprintNumber(24,0, freq1, 5);
+
+ poke(PSG_RAM,freqA & 0xFF);
+ poke(PSG_RAM+1,(freqA & 0xFF00)/255);
+ poke(PSG_RAM+2,freqB & 0xFF);
+ poke(PSG_RAM+3,(freqB & 0xFF00)/255);
+
+ env_step=0;
+ }
+
+
+ // control de posicion de pattern
+ pattern_step++;
+ if(pattern_step>15)pattern_step=0;
+ }else{
+ tempoStep++;
+ poke(PSG_RAM+13,0); //envelope wave form
+ drum_type=0;
+ }
+
+
+
+
+ if (isTone==true)
+ {
+ //control de volumen del tono (envolvente) #############################
+ amp = env_list[env_selected].ampValues[env_step];
+
+ // calcula siguiente posicion.
+ env_step+=env_speed;
+
+ if (env_step>15) //control de tamaño de envolvente
+ {
+ if (env_list[env_selected].isLoop==true) env_step=0;
+ else env_step=15; // ultimo valor de la envolvente
+ }
+
+ }else{
+ amp=0;
+ }
+
+ poke(PSG_RAM+8,amp);
+ if(isAB==true) poke(PSG_RAM+9,amp);
+ else poke(PSG_RAM+9,0);
+
+
+ //sound_set(8,amp);
+ //sound_set(9,amp);
+
+ //variacion = env00[pasos] * 2;
+
+
+ //sound_set(0,freq1 & 0xFF);
+ //sound_set(1,(freq1 & 0xFF00)/255);
+ //sound_set(2,freq2 & 0xFF);
+ //sound_set(3,(freq2 & 0xFF00)/255);
+
+
+
+ // VISUALS ###############################################################
+ setSpritePos(0,xvalues[stone_step],yvalues[stone_step]);
+ setSpritePat(0,amp/2);// /2
+ setSpriteCol(0,15);
+ stone_step++;
+ if (stone_step>63) stone_step=0;
+
+ if (isDrum==false)
+ {
+ poke(PSG_RAM+10,0); //volumen canal C
+ sdrum_size=0;
+ }
+
+/* else
+ {
+ if (drum_type>0){
+ sdrum_size=7;
+ sdrum_color=drumcolor[drum_type];
+ }
+ }*/
+
+ if(sdrum_size==0) sdrum_color=drumcolor[0];
+ setSpritePos(1,xvalues[sdrum_step],yvalues[sdrum_step]);
+ setSpritePat(1,sdrum_size);
+ setSpriteCol(1,sdrum_color);
+
+ if (sdrum_size>0) sdrum_size--;
+ //vprintNumber(24,0, sdrum_size, 3); //test
+ sdrum_step++;
+ if (sdrum_step>63) sdrum_step=0;
+ // END VISUALS ###########################################################
+
+
+
+ joyval=joystick(0);
+ if(joyval==0) joyval=joystick(1);
+
+ if (joyval>0)
+ {
+ if (joybool==false)
+ {
+ joybool = true;
+ vpoke(vaddr_cursor[cursor_pos],32);
+
+ if(joyval==1) // arriba
+ {
+ cursor_pos--;
+ if(cursor_pos<0)cursor_pos=8;
+ }
+ if(joyval==5) // abajo
+ {
+ cursor_pos++;
+ if(cursor_pos>8)cursor_pos=0;
+ }
+ if(joyval==3) // right
+ {
+ switch (cursor_pos) //{0x1841,0x1901,0x19A1,0x19C1,0x1A01,0x1A21,0x1A41,0x1A81,0x1AA1};
+ {
+ case 0: //tempo
+ if (Tempo<8) Tempo++;
+ vprintNumber(8,2, Tempo, 1);
+ break;
+ case 1: //CASIO DRUMS?
+ isCasio=true;
+ switcher(0x1909,true);
+ break;
+ case 2: //A+B
+ isAB=true;
+ switcher(0x19A9,true);
+ break;
+ case 3: //B offset
+ if (B_offset<254) B_offset++;
+ vprintNumber(6,14, B_offset, 3);
+ break;
+ case 4: //envelope wave
+ if (env_selected<7) env_selected++;
+ showEnv(env_selected);
+ switcher(0x1A49,env_list[env_selected].isLoop);
+ break;
+ case 5: //envelope speed
+ if (env_speed<3) env_speed++;
+ vprintNumber(8,17, env_speed, 1);
+ break;
+ case 6: //loop
+ env_list[env_selected].isLoop=true;
+ switcher(0x1A49,true);
+ break;
+ case 7: // octave +
+ if (octave<6) octave++;
+ vprintNumber(8,20, octave, 1);
+ break;
+ case 8:
+ //if (_noteOffset<9) _noteOffset++;
+ //vprintNumber(8,21, _noteOffset, 1);
+ upNotePattern();
+ break;
+ }
+ }
+ if(joyval==7) // left
+ {
+ switch (cursor_pos)
+ {
+ case 0:
+ if (Tempo>1) Tempo--;
+ vprintNumber(8,2, Tempo, 1);
+ break;
+ case 1:
+ isCasio=false;
+ switcher(0x1909,false);
+ break;
+ case 2:
+ isAB=false;
+ switcher(0x19A9,isAB);
+ break;
+ case 3:
+ if (B_offset>0) B_offset--;
+ vprintNumber(6,14, B_offset, 3);
+ break;
+ case 4:
+ if (env_selected>0) env_selected--;
+ showEnv(env_selected);
+ switcher(0x1A49,env_list[env_selected].isLoop);
+ break;
+ case 5:
+ if (env_speed>0) env_speed--;
+ vprintNumber(8,17, env_speed, 1);
+ break;
+ case 6:
+ env_list[env_selected].isLoop=false;
+ switcher(0x1A49,false);
+ break;
+ case 7: //octave -
+ if (octave>1) octave--;
+ vprintNumber(8,20, octave, 1);
+ break;
+ case 8:
+ //if (_noteOffset>-9) _noteOffset--;
+ //vprintNumber(8,21, _noteOffset, 1);
+ //modifyTonePattern();
+ downNotePattern();
+ break;
+ }
+ }
+ vpoke(vaddr_cursor[cursor_pos],186);
+ }
+ }else{
+ joybool = false;
+ }
+
+
+
+
+ keyPressed = SNSMAT(6);
+ if (keyPressed!=0xFF)
+ {
+ if(keyB6semaphore==false)
+ {
+ switch (keyPressed)
+ {
+ /* case 0xFE: //0 SHIFT
+ fxMode=4;
+ keyB6semaphore=true;
+ break;*/
+
+ /* case 0xFD: //1 CTRL
+ fxMode=3;
+ keyB6semaphore=true;
+ break;*/
+
+ /* case 0xFB: //2 GRAPH
+
+ keyB6semaphore=true;
+ break;*/
+
+ /* case 0xF7: //3 CAPS
+ keyB6semaphore=true;
+ break;*/
+
+ /* case 0xEF: // 4 CODE
+
+ keyB6semaphore=true;
+ break;*/
+
+ case 0xDF: // 5 [F1]
+ genDrumPattern();
+ genTonePattern();
+
+ keyB6semaphore=true;
+ break;
+
+ case 0xBF: // 6 [F2]
+ genDrumPattern();
+
+ keyB6semaphore=true;
+ break;
+
+ case 0x7F: // 7 [F3]
+ genTonePattern();
+
+ keyB6semaphore=true;
+ break;
+
+ //default:
+ // break;
+ }
+ }
+ }else keyB6semaphore=false;
+
+ keyPressed = SNSMAT(7);
+ if (keyPressed!=0xFF)
+ {
+ if(keyB7semaphore==false)
+ {
+ switch (keyPressed)
+ {
+ case 0xFE: // [F4]
+ if(isDrum==true) isDrum=false;
+ else isDrum=true;
+
+ showSpeaker(0x18CA,isDrum);
+
+ keyB7semaphore=true;
+ break;
+
+ case 0xFD: // [F5]
+ if(isTone==true) isTone=false;
+ else isTone=true;
+
+ showSpeaker(0x198A,isTone);
+
+ keyB7semaphore=true;
+ break;
+
+/* case 0xFB: // [ESC]
+
+ keyB7semaphore=true;
+ break;*/
+
+/* case 0xF7: // [TAB]
+
+ keyB7semaphore=true;
+ break;*/
+
+ case 239: // [STOP]
+ isDrum=false;
+ isTone=false;
+ showSpeaker(0x18CA,false);
+ showSpeaker(0x198A,false);
+ keyB7semaphore=true;
+ break;
+
+/* case 223: // [BS] Scrolltext negative/positive
+
+ keyB7semaphore=true;
+ break;*/
+
+ case 191: // [SELECT] BG/noise OFF
+ if(isCasio==true) isCasio=false;
+ else isCasio=true;
+ switcher(0x1909,isCasio);
+ keyB7semaphore=true;
+ break;
+
+/* case 127: // [RETURN] Flash efect
+
+ keyB7semaphore=true;
+ break;*/
+
+ //default:
+ //break;
+ }
+ }
+ }else keyB7semaphore=false;
+
+ }
+
+}
+
+
+void checkMSX(void)
+{
+
+ // identifica modelo de MSX
+ //0 - MSX1, 1 - MSX2, 2 - MSX2+, 3 - TR, 4 - OCM
+ VDP_type = peek(0x2D);
+
+
+//2BH b7 Periodo de sincronismo (VSYNC) 0:60Hz 1:50Hz
+/*
+ ld a,($ffe8)
+ bit 1,a
+ jr z,its_60hz
+
+ ;its_50Hz
+
+its_60hz:
+
+ */
+
+
+}
+
+
+
+// activa tono y ruido de uno de los tres canales del PSG
+void setChannel(byte NumChannel, boolean isTone, boolean isNoise)
+{
+ byte newValue;
+
+ newValue = sound_get(7);
+
+ if(NumChannel==0)
+ {
+ if(isTone==true){newValue&=254;}else{newValue|=1;}
+ if(isNoise==true){newValue&=247;}else{newValue|=8;}
+ }
+ if(NumChannel==1)
+ {
+ if(isTone==true){newValue&=253;}else{newValue|=2;}
+ if(isNoise==true){newValue&=239;}else{newValue|=16;}
+ }
+ if(NumChannel==2)
+ {
+ if(isTone==true){newValue&=251;}else{newValue|=4;}
+ if(isNoise==true){newValue&=223;}else{newValue|=32;}
+ }
+ //sound_set(7,newValue);
+ poke(PSG_RAM+7,newValue);
+}
+
+
+void sound_set(byte reg, byte val)
+{
+reg;
+val;
+__asm
+ ld a, 4(ix)
+ ld e, 5(ix)
+ call 0x0093
+__endasm;
+}
+
+
+
+byte sound_get(byte reg)
+{
+reg;
+__asm
+ ld A,4(ix)
+ call 0x0096
+ ld L,A
+__endasm;
+}
+
+
+
+void showLogoScreen()
+{
+__asm
+ ld hl,#TILESET1_B0
+ ld de,#BASE12
+ call unRLE2VR
+
+ ld hl,#TILESET1_B1
+ ld de,#BASE12 + 2048
+ call unRLE2VR
+
+ ld hl,#TILESET1_B2
+ ld de,#BASE12 + 4096
+ call unRLE2VR
+
+ ld hl,#TILESET1_col_B0
+ ld de,#BASE11
+ call unRLE2VR
+
+ ld hl,#TILESET1_col_B1
+ ld de,#BASE11 + 2048
+ call unRLE2VR
+
+ ld hl,#TILESET1_col_B2
+ ld de,#BASE11 + 4096
+ call unRLE2VR
+
+ ld bc,#32*4 ;32* num sprites
+ ld hl,#LOGO_SPR
+ ld de,#BASE14
+ call 0x005C
+
+ ret
+
+
+; tileset
+; pattern data BANK0
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:799
+TILESET1_B0:
+.db 0x04,0x00,0x02,0x03,0x06,0x00,0x02,0xF6,0x02,0xC7,0x06,0x00,0x01,0x87,0x01,0xCF
+.db 0x07,0x00,0x01,0x80,0x04,0x00,0x02,0x1C,0x01,0x36,0x01,0x37,0x04,0x00,0x02,0x38
+.db 0x02,0x18,0x06,0x00,0x01,0x39,0x01,0x3D,0x06,0x00,0x01,0xE0,0x01,0xF0,0x04,0x00
+.db 0x02,0x07,0x02,0x06,0x04,0x00,0x02,0x80,0x01,0xC3,0x01,0xE3,0x06,0x00,0x01,0x9E
+.db 0x01,0xDF,0x04,0x00,0x02,0x03,0x01,0x0F,0x01,0x1F,0x06,0x00,0x01,0x38,0x01,0x7C
+.db 0x06,0x00,0x01,0xC4,0x01,0xEE,0x06,0x00,0x01,0x70,0x01,0xF0,0x04,0x00,0x04,0x03
+.db 0x04,0x00,0x02,0xC0,0x01,0x67,0x01,0x77,0x06,0x00,0x01,0xC7,0x01,0xEF,0x04,0x00
+.db 0x02,0x03,0x01,0x00,0x01,0x83,0x06,0x00,0x01,0x1C,0x01,0x3E,0x06,0x00,0x01,0x38
+.db 0x01,0x7C,0x04,0x00,0x02,0x30,0x02,0x78,0x06,0x00,0x02,0x03,0x06,0x00,0x01,0x33
+.db 0x01,0x37,0x06,0x00,0x01,0x80,0x01,0xC0,0x04,0x00,0x02,0x38,0x01,0x6C,0x01,0x6E
+.db 0x04,0x00,0x02,0xC0,0x01,0xF0,0x01,0xF8,0x30,0x00,0x08,0xC6,0x01,0xCD,0x02,0x6F
+.db 0x03,0x6C,0x01,0x6F,0x01,0x67,0x03,0x80,0x02,0x00,0x02,0xC0,0x01,0x80,0x01,0x33
+.db 0x02,0x3F,0x05,0x33,0x06,0x18,0x02,0x7E,0x01,0x0D,0x02,0x7D,0x03,0xCD,0x01,0xFD
+.db 0x01,0x7D,0x01,0xB0,0x07,0x98,0x03,0x06,0x02,0x07,0x03,0x06,0x01,0x60,0x02,0x67
+.db 0x02,0xCC,0x01,0x8C,0x01,0xCF,0x01,0xC7,0x01,0xDB,0x07,0xD9,0x01,0x1B,0x05,0xB3
+.db 0x01,0xBF,0x01,0x9F,0x01,0x6C,0x05,0x66,0x01,0x7E,0x01,0x3C,0x03,0xFE,0x02,0xD6
+.db 0x03,0xC6,0x01,0xC0,0x02,0x78,0x02,0x0C,0x01,0xCC,0x01,0xFC,0x01,0x78,0x08,0x03
+.db 0x03,0x36,0x02,0xE6,0x03,0x06,0x01,0x6D,0x05,0x0C,0x01,0x0F,0x01,0x07,0x01,0x83
+.db 0x05,0xC3,0x01,0xCB,0x01,0x8B,0x01,0x36,0x02,0x3E,0x02,0x30,0x01,0x33,0x01,0x3F
+.db 0x01,0x1E,0x01,0x64,0x04,0x60,0x01,0x66,0x01,0x7E,0x01,0x3C,0x05,0x30,0x01,0x34
+.db 0x01,0x3C,0x01,0x18,0x01,0x03,0x04,0x01,0x03,0x00,0x01,0x36,0x02,0xE6,0x02,0xE7
+.db 0x02,0xC7,0x01,0xC3,0x01,0xC0,0x04,0xE0,0x01,0x66,0x01,0xE6,0x01,0xC6,0x03,0x66
+.db 0x02,0x3E,0x01,0x06,0x01,0x0E,0x01,0x0C,0x01,0xD8,0x05,0xCC,0x01,0xFC,0x01,0xF8
+.db 0x34,0x00,0x02,0xC0,0x01,0xF1,0x01,0xF9,0x06,0x00,0x02,0x98,0x06,0x00,0x01,0x06
+.db 0x01,0x07,0x06,0x00,0x01,0x26,0x01,0x76,0x06,0x00,0x02,0x63,0x06,0x00,0x01,0x8E
+.db 0x01,0xDF,0x04,0x00,0x02,0x3F,0x01,0x03,0x01,0x07,0x04,0x00,0x03,0x06,0x01,0x0C
+.db 0x02,0x60,0x02,0x00,0x02,0x38,0x01,0x0C,0x01,0x1D,0x06,0x00,0x01,0xE0,0x01,0xF0
+.db 0x04,0x00,0x02,0xE6,0x01,0x37,0x01,0x77,0x06,0x00,0x01,0x87,0x01,0xCF,0x06,0x00
+.db 0x01,0x1E,0x01,0x9F,0x0C,0x00,0x02,0x3C,0x01,0x06,0x01,0x1E,0x06,0x00,0x01,0x70
+.db 0x01,0xF8,0x04,0x00,0x02,0x61,0x02,0xE0,0x02,0x06,0x02,0x00,0x02,0xE0,0x01,0x30
+.db 0x01,0xF0,0x70,0x00,0x01,0xD9,0x04,0xCD,0x01,0xCC,0x01,0xFC,0x01,0xF8,0x05,0x98
+.db 0x02,0xF8,0x01,0x18,0x03,0x07,0x05,0x06,0x01,0xF6,0x02,0xF3,0x02,0xB3,0x03,0x31
+.db 0x01,0x60,0x02,0xC7,0x02,0xCC,0x01,0x8C,0x01,0x8F,0x01,0x87,0x01,0xD9,0x04,0xD8
+.db 0x01,0xD9,0x01,0xDF,0x01,0xCF,0x01,0x06,0x04,0x0C,0x02,0x8C,0x03,0x0C,0x03,0x18
+.db 0x03,0x30,0x01,0x19,0x02,0x0D,0x02,0x4D,0x01,0xCD,0x01,0xFD,0x01,0x78,0x01,0xB0
+.db 0x02,0xB8,0x02,0xF9,0x01,0xDB,0x01,0xFB,0x01,0xF1,0x01,0x66,0x05,0x36,0x01,0xF7
+.db 0x01,0xE7,0x01,0xCC,0x05,0x6C,0x01,0xEF,0x01,0xC7,0x01,0x9B,0x04,0x19,0x02,0xD9
+.db 0x01,0x99,0x01,0x00,0x07,0x80,0x01,0x1C,0x02,0x30,0x03,0x60,0x02,0x7E,0x01,0xD8
+.db 0x02,0xDC,0x02,0xFC,0x01,0xEC,0x01,0xFD,0x01,0x79,0x01,0x60,0x02,0x61,0x03,0x63
+.db 0x02,0xFB,0x01,0xE0,0x02,0x80,0x03,0x00,0x02,0xF0,0x78,0x00,0x02,0xF0,0xAC,0x00
+.db 0x01,0x01,0x01,0x03,0x05,0x00,0x01,0x07,0x02,0xFF,0x04,0x00,0x04,0xFF,0x04,0x00
+.db 0x04,0xFF,0x05,0x00,0x01,0xF0,0x02,0xFF,0x07,0x00,0x01,0xC0,0x18,0x00,0xB3,0xFF
+.db 0x01,0xFC,0x01,0xF8,0x01,0xF0,0x01,0xE0,0x01,0xC0,0x01,0xE0,0x01,0xC0,0x26,0x00
+.db 0x01,0x0F,0x01,0x07,0x01,0x03,0x01,0x01,0x04,0x00,0x05,0xFF,0x02,0x7F,0x01,0x3F
+.db 0xBB,0xFF,0x02,0xFE,0x01,0xFC,0x01,0xF8,0x01,0xF9,0x02,0x80,0x04,0x00,0x01,0x40
+.db 0x01,0xC0,0x30,0x00,0x02,0x1F,0x03,0x0F,0x02,0x07,0x01,0x03,0x58,0xFF,0x04,0x00
+.db 0x01,0x03,0x01,0x0F,0x02,0x1F,0x03,0x00,0x01,0x70,0x01,0xFC,0x03,0xFF,0x06,0x00
+.db 0x02,0x80,0x02,0x00,0x01,0x07,0x01,0x1F,0x01,0x3F,0x02,0x7F,0x01,0xFE,0x02,0x00
+.db 0x01,0xE0,0x01,0xF8,0x02,0xFC,0x01,0xFE,0x01,0x3F,0x38,0xFF,0x01,0xF9,0x02,0xFB
+.db 0x05,0xF7,0x01,0xC0,0x07,0x80,0x30,0x00,0x04,0x03,0x04,0x01,0x10,0xFF,0x00
+
+; pattern data BANK1
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:507
+TILESET1_B1:
+.db 0x48,0x00,0x05,0x3F,0x02,0x1F,0x01,0x0F,0x01,0x00,0x01,0x70,0x03,0xF8,0x01,0x70
+.db 0x01,0x00,0x01,0x01,0x04,0x3F,0x02,0x7F,0x02,0xFF,0x03,0x03,0x01,0x01,0x01,0x80
+.db 0x01,0xC0,0x01,0xE0,0x01,0xF0,0x03,0xE0,0x01,0xC0,0x02,0x01,0x01,0x03,0x01,0x07
+.db 0x38,0xFF,0x01,0xF7,0x01,0xFF,0x04,0xF7,0x01,0xFF,0x01,0xF7,0x08,0x80,0x30,0x00
+.db 0x01,0x01,0x07,0x00,0x10,0xFF,0x48,0x00,0x08,0x01,0x07,0xFC,0x01,0xF8,0x04,0x00
+.db 0x02,0xFF,0x01,0x80,0x01,0xFF,0x04,0xF8,0x03,0xF0,0x01,0xF8,0x01,0xF0,0x03,0xE0
+.db 0x04,0xC0,0x38,0xFF,0x01,0xF7,0x02,0xFF,0x02,0xFB,0x03,0xFF,0x03,0x80,0x03,0xC0
+.db 0x02,0xE0,0x30,0x00,0x02,0xFF,0x05,0xFE,0x01,0xFC,0x52,0xFF,0x01,0xFC,0x01,0xF0
+.db 0x02,0xE0,0x02,0xC0,0x01,0xFD,0x01,0xF9,0x01,0x70,0x01,0x03,0x01,0x07,0x01,0x0F
+.db 0x01,0x1F,0x01,0x3F,0x01,0x04,0x0F,0x00,0x01,0x18,0x07,0x00,0x01,0xBF,0x01,0x9C
+.db 0x01,0xC0,0x01,0xE0,0x01,0xF0,0x02,0xF8,0x01,0xFC,0x01,0xFF,0x01,0x1F,0x01,0x0F
+.db 0x01,0x07,0x02,0x03,0x02,0x01,0x38,0xFF,0x03,0xF0,0x02,0xF8,0x02,0xFC,0x01,0xFE
+.db 0x30,0x00,0x02,0xFC,0x02,0xF8,0x01,0xF0,0x01,0xE0,0x01,0xC0,0x01,0x80,0x50,0xFF
+.db 0x04,0xC0,0x01,0xE0,0x01,0xF8,0x02,0xFE,0x01,0xC0,0x05,0x80,0x07,0x00,0x02,0x01
+.db 0x07,0x00,0x01,0x80,0x01,0xC0,0x04,0x00,0x02,0x10,0x01,0x30,0x01,0x60,0x04,0x01
+.db 0x04,0x00,0x03,0xFE,0x01,0xFC,0x01,0xF8,0x01,0xE0,0x02,0xC0,0x40,0xFF,0x01,0x00
+.db 0x01,0x80,0x01,0xE0,0x01,0xF0,0x01,0xF8,0x01,0xFC,0x02,0xFF,0x07,0x00,0x01,0xF0
+.db 0x0F,0x00,0x01,0x01,0x05,0x00,0x01,0x01,0x01,0x0F,0x01,0xFF,0x01,0x00,0x01,0x01
+.db 0x01,0x03,0x01,0x0F,0x01,0x7F,0x1B,0xFF,0x3E,0x00,0x01,0x01,0x01,0x1F,0x04,0x01
+.db 0x01,0x03,0x01,0x1F,0x01,0xF8,0x01,0xC0,0x10,0x00,0x01,0x71,0x01,0x1F,0x06,0x00
+.db 0x01,0xC0,0x0F,0x00,0x02,0xC0,0x02,0xE0,0x01,0xFF,0x01,0x7F,0x06,0x00,0x01,0xF8
+.db 0x01,0xFF,0x01,0x1F,0x06,0x00,0x01,0x80,0x01,0xF0,0x01,0xFC,0xA9,0x00,0x03,0x01
+.db 0x04,0x03,0x01,0xFC,0x01,0xE0,0x01,0xC0,0x02,0x80,0x0A,0x00,0x01,0x3F,0x1D,0x00
+.db 0x01,0x09,0x01,0x1D,0x01,0x14,0x05,0x00,0x01,0x10,0x01,0xB0,0x01,0xE0,0x06,0x00
+.db 0x01,0x3F,0x01,0x7F,0x06,0x00,0x01,0xF8,0x01,0xFE,0x01,0x0F,0x01,0x03,0x02,0x01
+.db 0x05,0x00,0x02,0x80,0x05,0xC0,0xA0,0x00,0x08,0x07,0x09,0xFF,0x01,0xF0,0x01,0xE0
+.db 0x03,0xC0,0x02,0xE0,0x08,0x80,0x10,0x00,0x01,0x3E,0x02,0x22,0x05,0x00,0x03,0x40
+.db 0x05,0x00,0x08,0xE0,0x01,0x0F,0x01,0x07,0x06,0x03,0x08,0x00,0x07,0xC0,0x01,0x80
+.db 0xA0,0x00,0x02,0x03,0x02,0x01,0x04,0x00,0x02,0x80,0x01,0xC0,0x01,0xE1,0x01,0xFF
+.db 0x01,0x3F,0x02,0x00,0x03,0xF1,0x01,0xE1,0x01,0xC1,0x01,0x81,0x02,0x01,0x08,0x80
+.db 0x20,0x00,0x07,0xE0,0x01,0xFC,0x01,0x03,0x02,0x01,0x05,0x00,0x01,0x01,0x01,0x83
+.db 0x01,0xFE,0x01,0x78,0x04,0x00,0x01,0x80,0x77,0x00,0x00
+
+; pattern data BANK2
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:413
+TILESET1_B2:
+.db 0x40,0x00,0x08,0x03,0x16,0xFF,0x01,0xC0,0x01,0x80,0x06,0xFF,0x01,0xF8,0x01,0xFE
+.db 0x08,0xFF,0x01,0xFE,0x01,0x0F,0x01,0x07,0x03,0x03,0x02,0x01,0x04,0x00,0x04,0x80
+.db 0xC0,0x00,0x08,0xFC,0x06,0xFF,0x02,0x80,0x01,0xFF,0x07,0xFE,0x01,0xE0,0x01,0xC0
+.db 0x06,0x80,0x01,0xF0,0x01,0xF8,0x02,0xFC,0x04,0xFE,0x03,0xFF,0x05,0x80,0x08,0x01
+.db 0x08,0x80,0x80,0x00,0x26,0xFF,0x01,0xFE,0x01,0x80,0x05,0x00,0x01,0x1F,0x01,0xFC
+.db 0x05,0x00,0x01,0x0F,0x01,0xFE,0x05,0x00,0x01,0x0F,0x04,0xFF,0x01,0xFE,0x03,0xFF
+.db 0x01,0x80,0x03,0x00,0x01,0xC0,0x01,0xF0,0x01,0x80,0x01,0xFF,0x04,0x00,0x01,0xFC
+.db 0x01,0xC0,0x02,0xFF,0x04,0x00,0x04,0xFF,0x04,0x00,0x03,0xFE,0x02,0x00,0x01,0xE0
+.db 0x01,0xF8,0x01,0xFE,0x06,0x80,0x01,0xC0,0x01,0xE0,0x06,0x01,0x01,0x03,0x01,0x07
+.db 0x05,0x7F,0x01,0x03,0x01,0x07,0x07,0x00,0x01,0xFE,0x01,0x01,0x07,0x00,0x01,0xFE
+.db 0x76,0x00,0x01,0x07,0x01,0x3F,0x04,0x00,0x01,0x0F,0x01,0xF8,0x01,0xC0,0x01,0x00
+.db 0x02,0xFF,0x02,0xF0,0x04,0x00,0x01,0x0F,0x01,0xFF,0x01,0x80,0x05,0x00,0x01,0xE0
+.db 0x3F,0x00,0x01,0x01,0x07,0x00,0x01,0x80,0x01,0xC0,0x01,0x7F,0x05,0x00,0x01,0xFE
+.db 0x01,0xF8,0x01,0xF0,0x15,0x00,0x01,0x01,0x07,0x00,0x01,0xF8,0x01,0x07,0x07,0x00
+.db 0x01,0xF0,0x01,0x3F,0x01,0x01,0x04,0x00,0x02,0xFF,0x01,0x3F,0x01,0x01,0x01,0xF8
+.db 0x03,0xFF,0x04,0x00,0x01,0xF0,0x01,0x80,0x01,0xF8,0x01,0xFF,0x06,0x00,0x01,0xFC
+.db 0x01,0x1F,0x07,0x00,0x01,0xE0,0x40,0x00,0x01,0xF8,0x01,0xC0,0xB6,0x00,0x01,0x7F
+.db 0x01,0x0F,0x07,0x00,0x01,0xF0,0x01,0x7F,0x01,0x0F,0x07,0x00,0x01,0xF0,0x01,0xFE
+.db 0x01,0xF0,0x02,0xFF,0x05,0x00,0x01,0xF0,0x01,0xFE,0x01,0x1F,0x07,0x00,0x01,0x80
+.db 0xF0,0x00,0x01,0x01,0x07,0x00,0x01,0xFC,0x01,0x1F,0x01,0x03,0x06,0x00,0x01,0x80
+.db 0x01,0xFC,0x01,0x7F,0x01,0x0F,0x01,0x01,0x02,0x00,0x03,0xFF,0x01,0x80,0x01,0xF0
+.db 0x01,0xFF,0x01,0xC0,0x01,0xF0,0x06,0x00,0x01,0xE0,0x01,0xF8,0xF8,0x00,0x01,0xFF
+.db 0x01,0x3F,0x01,0x0F,0x01,0x01,0x05,0x00,0x01,0xF0,0x02,0xFF,0x01,0x3F,0x01,0x0F
+.db 0x01,0x03,0xE3,0x00,0x01,0x3C,0x04,0x2A,0x03,0x00,0x01,0x8B,0x01,0x88,0x01,0x89
+.db 0x01,0x52,0x01,0x21,0x03,0x00,0x01,0xC7,0x01,0x28,0x01,0xE8,0x01,0x28,0x01,0xE7
+.db 0x02,0x00,0x01,0x78,0x02,0x08,0x01,0x10,0x02,0x20,0x01,0x00,0x00
+
+; color data BANK0
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:43
+TILESET1_col_B0:
+.db 0xFF,0xF5,0xFF,0xF5,0x0A,0xF5,0x40,0xE5,0x02,0xF5,0x46,0xE5,0x02,0xF5,0x06,0xE5
+.db 0x70,0xF5,0x90,0xE5,0x68,0xF5,0x18,0xE5,0xE8,0x75,0xFF,0x57,0xFF,0x57,0x4A,0x57
+.db 0x1F,0x35,0x01,0x31,0x07,0x35,0x01,0x31,0x90,0x57,0x00
+
+; color data BANK1
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:141
+TILESET1_col_B1:
+.db 0x50,0x35,0x07,0x13,0x09,0x53,0x04,0x13,0x04,0x53,0x04,0x13,0x04,0x53,0x90,0x57
+.db 0x55,0x35,0x02,0x31,0x01,0x3C,0x06,0x15,0x01,0x1C,0x01,0x35,0x05,0x53,0x02,0x13
+.db 0x01,0xC3,0x08,0x35,0x78,0x57,0x02,0x71,0x06,0x75,0x10,0x57,0x4B,0x51,0x05,0x31
+.db 0x01,0xC3,0x05,0x13,0x02,0x53,0x04,0x13,0x04,0x53,0x01,0xC3,0x05,0x13,0x02,0x53
+.db 0x02,0x51,0x06,0x31,0x08,0x51,0x70,0x57,0x08,0x75,0x10,0x57,0x47,0x51,0x01,0x5C
+.db 0x03,0x13,0x05,0xC3,0x1A,0x13,0x06,0xC3,0x06,0x15,0x02,0xC5,0x88,0x57,0x46,0xC5
+.db 0x02,0xC3,0x10,0x53,0x18,0x13,0x04,0xC5,0x04,0xC3,0x05,0xC5,0x03,0xC3,0xB8,0xC5
+.db 0x50,0xC3,0xB0,0xC5,0x08,0x3C,0x08,0xC5,0x28,0xC3,0x10,0xC5,0x08,0xC3,0xB0,0xC5
+.db 0x05,0xC3,0x0B,0xC5,0x28,0xC3,0x10,0xC5,0x02,0xC3,0x7E,0xC5,0x00
+
+; color data BANK2
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:189
+TILESET1_col_B2:
+.db 0x48,0xC5,0x04,0x3F,0x04,0x35,0x06,0x3F,0x02,0x35,0x06,0x3F,0x02,0x3C,0x06,0x3F
+.db 0x02,0xC3,0x06,0x3F,0x02,0x35,0x01,0xC5,0x07,0xC3,0xC8,0xC5,0x08,0x5C,0x03,0x3F
+.db 0x03,0x35,0x02,0xC3,0x01,0x35,0x07,0x3C,0x08,0xC5,0x08,0x5C,0x03,0x35,0x0D,0xC3
+.db 0x88,0xC5,0x28,0x51,0x06,0x15,0x02,0x16,0x05,0x15,0x03,0x16,0x05,0x15,0x03,0x61
+.db 0x03,0x5C,0x05,0x16,0x02,0xC3,0x01,0x51,0x05,0x16,0x02,0x3C,0x06,0x16,0x02,0x51
+.db 0x06,0x16,0x03,0x5C,0x05,0x61,0x10,0xC3,0x05,0x5C,0x01,0x51,0x02,0x16,0x07,0x15
+.db 0x01,0x16,0x85,0x15,0x03,0x16,0x03,0x51,0x05,0x16,0x01,0x15,0x4F,0x16,0x02,0x1C
+.db 0x06,0x16,0x02,0xC6,0x01,0x16,0x05,0x56,0x18,0x16,0x01,0x15,0x07,0x16,0x02,0x15
+.db 0x06,0x16,0x04,0x51,0x04,0x61,0x05,0x15,0x03,0x61,0x07,0x15,0x01,0x16,0x48,0x15
+.db 0xC0,0x16,0x02,0x15,0x06,0x16,0x05,0x15,0x03,0x61,0x07,0x15,0x01,0x16,0x28,0x15
+.db 0xD8,0x16,0x01,0x15,0x07,0x16,0x03,0x15,0x05,0x16,0x03,0x55,0x03,0x15,0x02,0x61
+.db 0x10,0x15,0xF8,0x16,0x04,0x15,0xE4,0x16,0x18,0xE6,0x08,0x76,0x00
+
+LOGO_SPR:
+; 01
+.db 0x01,0x0F,0x38,0x60,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0x40,0x60,0x30,0x18,0x0C,0x06
+.db 0xC0,0xF0,0x1C,0x06,0x06,0x03,0x03,0x03,0x03,0x02,0x06,0x04,0x08,0x08,0x18,0x18
+; 02
+.db 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,0x04,0x08,0x10,0x20,0x40,0x40,0x80,0x80
+.db 0x08,0x08,0x08,0x08,0x0F,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+; 03
+.db 0x07,0x1C,0x30,0x60,0x40,0xC0,0xC0,0xC0,0xC0,0xE0,0x60,0x30,0x18,0x0C,0x04,0x06
+.db 0xE0,0x38,0x0C,0x04,0x06,0x03,0x03,0x03,0x03,0x03,0x06,0x06,0x0C,0x18,0x10,0x20
+; 04
+.db 0x06,0x06,0x0C,0x0C,0x0C,0x78,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.db 0x20,0x60,0x40,0x40,0x40,0xC0,0x80,0x80,0x40,0x20,0x10,0x08,0x08,0x04,0x02,0x02
+
+
+
+__endasm;
+}
+
+
+
+void setTileset()
+{
+__asm
+ ld bc,#2048
+ ld hl,#TILESET_B0
+ ld de,#BASE12
+ call 0x005C
+
+ ld bc,#2048
+ ld hl,#TILESET_B0
+ ld de,#BASE12 + 2048
+ call 0x005C
+
+ ld bc,#2048
+ ld hl,#TILESET_B0
+ ld de,#BASE12 + 4096
+ call 0x005C
+
+ ld hl,#TILESET_col_B0
+ ld de,#BASE11
+ call unRLE2VR
+
+ ld hl,#TILESET_col_B0
+ ld de,#BASE11 + 2048
+ call unRLE2VR
+
+ ld hl,#TILESET_col_B0
+ ld de,#BASE11 + 4096
+ jp unRLE2VR
+
+
+
+; tileset
+; pattern data BANK0
+; tiles: 0>255
+TILESET_B0:
+.db 0xFF,0xC1,0x9C,0x9C,0x9C,0xC1,0xFF,0x00,0xFF,0xE7,0xC7,0xE7,0xE7,0xC3,0xFF,0x00
+.db 0xFF,0x81,0xFC,0xC1,0x9F,0x80,0xFF,0xFF,0xFF,0x81,0xFC,0xE1,0xFC,0x81,0xFF,0xFF
+.db 0xFF,0x9C,0x9C,0x80,0xFC,0xFC,0xFF,0xFF,0xFF,0x80,0x9F,0x81,0xFC,0x81,0xFF,0xFF
+.db 0xFF,0xC1,0x9F,0x81,0x9C,0xC1,0xFF,0xFF,0xFF,0x80,0xFC,0xF9,0xF3,0xF3,0xFF,0xFF
+.db 0xFF,0xC1,0x9C,0xC1,0x9C,0xC1,0xFF,0xFF,0xFF,0xC1,0x9C,0xC0,0xFC,0xC1,0xFF,0x00
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xC3,0xFF,0xFF,0xFF,0x00
+.db 0xFF,0xFF,0xFF,0x11,0x57,0x57,0x11,0xFF,0xFF,0xFF,0xFF,0x11,0xB5,0xB1,0xB5,0xFF
+.db 0xFF,0xFF,0xFF,0x51,0x53,0x57,0xB1,0xFF,0x00,0x6E,0x48,0x4E,0x48,0x68,0x00,0x00
+.db 0x00,0xCC,0x24,0x44,0x84,0xEC,0x00,0x00,0x00,0xCC,0x24,0x44,0x24,0xCC,0x00,0x00
+.db 0x00,0xAC,0xA4,0xE4,0x24,0x2C,0x00,0x00,0x00,0xEC,0x84,0xC4,0x24,0xCC,0x00,0x00
+.db 0x00,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x60,0x78,0x7E,0x78,0x60,0x00,0x00
+.db 0x00,0x60,0x78,0x7E,0x78,0x60,0x00,0x00,0x00,0x7E,0x7E,0x7E,0x7E,0x7E,0x00,0x00
+.db 0x00,0x0F,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x88,0x88,0xF8,0x00,0x00
+.db 0x00,0x00,0x00,0x7B,0x0A,0x7A,0x0A,0x7B,0x00,0x00,0x00,0xDE,0x42,0x5E,0x42,0xDE
+.db 0x00,0x00,0x00,0x80,0xF7,0x94,0x94,0xF7,0x00,0x00,0x00,0x00,0xB8,0x24,0x24,0xA4
+.db 0xFF,0xFF,0x9C,0x9C,0xC9,0xE3,0xFF,0xFF,0xFF,0x9F,0x81,0x9C,0x9C,0x81,0xFF,0xFF
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xF3,0xF3,0xF3,0xFF,0xF3,0xFF
+.db 0xFF,0xEB,0xEB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEB,0xC1,0xEB,0xC1,0xEB,0xFF,0xFF
+.db 0xF7,0xC1,0x97,0xC1,0xF4,0xC1,0xF7,0xFF,0xFF,0xCC,0xC9,0xF3,0xE4,0xCC,0xFF,0xFF
+.db 0xFF,0xC7,0x93,0xC2,0x99,0xC2,0xFF,0xFF,0xFF,0xE7,0xCF,0xFF,0xFF,0xFF,0xFF,0xFF
+.db 0xF9,0xF3,0xF3,0xF3,0xF3,0xF3,0xF9,0xFF,0xCF,0xE7,0xE7,0xE7,0xE7,0xE7,0xCF,0xFF
+.db 0xFF,0xA5,0xC3,0x81,0xC3,0xA5,0xFF,0xFF,0xFF,0xE7,0xE7,0x81,0xE7,0xE7,0xFF,0xFF
+.db 0xFF,0xFF,0xFF,0xFF,0xE7,0xE7,0xEF,0xFF,0xFF,0xFF,0xFF,0x81,0xFF,0xFF,0xFF,0xFF
+.db 0xFF,0xFF,0xFF,0xFF,0xE7,0xE7,0xFF,0xFF,0xFF,0xF9,0xF3,0xE7,0xCF,0x9F,0xFF,0xFF
+.db 0xFF,0xC1,0x98,0x94,0x8C,0xC1,0xFF,0xFF,0xFF,0xE7,0xC7,0xE7,0xE7,0xC3,0xFF,0xFF
+.db 0xFF,0x81,0xFC,0xC1,0x9F,0x80,0xFF,0xFF,0xFF,0x81,0xFC,0xE1,0xFC,0x81,0xFF,0xFF
+.db 0xFF,0x9C,0x9C,0x80,0xFC,0xFC,0xFF,0xFF,0xFF,0x80,0x9F,0x81,0xFC,0x81,0xFF,0xFF
+.db 0xFF,0xC1,0x9F,0x81,0x9C,0xC1,0xFF,0xFF,0xFF,0x80,0xFC,0xF9,0xF3,0xF3,0xFF,0xFF
+.db 0xFF,0xC1,0x9C,0xC1,0x9C,0xC1,0xFF,0xFF,0xFF,0xC1,0x9C,0xC0,0xFC,0xC1,0xFF,0xFF
+.db 0xFF,0xE7,0xE7,0xFF,0xE7,0xE7,0xFF,0xFF,0xFF,0xE7,0xE7,0xFF,0xE7,0xE7,0xEF,0xFF
+.db 0xFF,0xF3,0xE7,0xCF,0xE7,0xF3,0xFF,0xFF,0xFF,0xFF,0xC3,0xFF,0xC3,0xFF,0xFF,0xFF
+.db 0xFF,0xCF,0xE7,0xF3,0xE7,0xCF,0xFF,0xFF,0xFF,0xE1,0xCC,0xF9,0xF3,0xFF,0xF3,0xFF
+.db 0xC1,0xBE,0xA2,0xAA,0xA0,0xBF,0xC1,0xFF,0xFF,0xC1,0x9C,0x80,0x9C,0x9C,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x81,0x9C,0x81,0xFF,0xFF,0xFF,0xC0,0x9F,0x9F,0x9F,0xC0,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x9C,0x9C,0x81,0xFF,0xFF,0xFF,0x80,0x9F,0x83,0x9F,0x80,0xFF,0xFF
+.db 0xFF,0x80,0x9F,0x83,0x9F,0x9F,0xFF,0xFF,0xFF,0xC0,0x9F,0x98,0x9C,0xC0,0xFF,0xFF
+.db 0xFF,0x9C,0x9C,0x80,0x9C,0x9C,0xFF,0xFF,0xFF,0xE1,0xF3,0xF3,0xF3,0xE1,0xFF,0xFF
+.db 0xFF,0xE1,0xF3,0xF3,0x93,0xC7,0xFF,0xFF,0xFF,0x9C,0x99,0x83,0x99,0x9C,0xFF,0xFF
+.db 0xFF,0x9F,0x9F,0x9F,0x9F,0x80,0xFF,0xFF,0xFF,0x9C,0x88,0x80,0x94,0x9C,0xFF,0xFF
+.db 0xFF,0x9C,0x8C,0x84,0x90,0x98,0xFF,0xFF,0xFF,0xC1,0x9C,0x9C,0x9C,0xC1,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x9C,0x81,0x9F,0xFF,0xFF,0xFF,0xC1,0x9C,0x94,0x99,0xC2,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x9C,0x81,0x9C,0xFF,0xFF,0xFF,0xC0,0x9F,0xC1,0xFC,0x81,0xFF,0xFF
+.db 0xFF,0x81,0xE7,0xE7,0xE7,0xE7,0xFF,0xFF,0xFF,0x9C,0x9C,0x9C,0x9C,0xC1,0xFF,0xFF
+.db 0xFF,0x9C,0x9C,0x9C,0xC9,0xE3,0xFF,0xFF,0xFF,0x9C,0x94,0x80,0x88,0x9C,0xFF,0xFF
+.db 0xFF,0x9C,0xC9,0xE3,0xC9,0x9C,0xFF,0xFF,0xFF,0x99,0x99,0xC3,0xE7,0xE7,0xFF,0xFF
+.db 0xFF,0x81,0xF3,0xE7,0xCF,0x81,0xFF,0xFF,0xF1,0xF3,0xF3,0xF3,0xF3,0xF3,0xF1,0xFF
+.db 0xFF,0x9F,0xCF,0xE7,0xF3,0xF9,0xFF,0xFF,0xC7,0xE7,0xE7,0xE7,0xE7,0xE7,0xC7,0xFF
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x81,0xFF
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC1,0x9C,0x80,0x9C,0x9C,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x81,0x9C,0x81,0xFF,0xFF,0xFF,0xC0,0x9F,0x9F,0x9F,0xC0,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x9C,0x9C,0x81,0xFF,0xFF,0xFF,0x80,0x9F,0x83,0x9F,0x80,0xFF,0xFF
+.db 0xFF,0x80,0x9F,0x83,0x9F,0x9F,0xFF,0xFF,0xFF,0xC0,0x9F,0x98,0x9C,0xC0,0xFF,0xFF
+.db 0xFF,0x9C,0x9C,0x80,0x9C,0x9C,0xFF,0xFF,0xFF,0xE1,0xF3,0xF3,0xF3,0xE1,0xFF,0xFF
+.db 0xFF,0xE1,0xF3,0xF3,0x93,0xC7,0xFF,0xFF,0xFF,0x9C,0x99,0x83,0x99,0x9C,0xFF,0xFF
+.db 0xFF,0x9F,0x9F,0x9F,0x9F,0x80,0xFF,0xFF,0xFF,0x9C,0x88,0x80,0x94,0x9C,0xFF,0xFF
+.db 0xFF,0x9C,0x8C,0x84,0x90,0x98,0xFF,0xFF,0xFF,0xC1,0x9C,0x9C,0x9C,0xC1,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x9C,0x81,0x9F,0xFF,0xFF,0xFF,0xC1,0x9C,0x94,0x99,0xC2,0xFF,0xFF
+.db 0xFF,0x81,0x9C,0x9C,0x81,0x9C,0xFF,0xFF,0xFF,0xC0,0x9F,0xC1,0xFC,0x81,0xFF,0xFF
+.db 0xFF,0x81,0xE7,0xE7,0xE7,0xE7,0xFF,0xFF,0xFF,0x9C,0x9C,0x9C,0x9C,0xC1,0xFF,0xFF
+.db 0xFF,0x9C,0x9C,0x9C,0xC9,0xE3,0xFF,0xFF,0xFF,0x9C,0x94,0x80,0x88,0x9C,0xFF,0xFF
+.db 0xFF,0x9C,0xC9,0xE3,0xC9,0x9C,0xFF,0xFF,0xFF,0x99,0x99,0xC3,0xE7,0xE7,0xFF,0xFF
+.db 0xFF,0x81,0xF3,0xE7,0xCF,0x81,0xFF,0xFF,0x00,0x18,0x18,0x00,0x18,0x18,0x00,0x00
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+.db 0x00,0xF0,0x92,0x92,0x12,0x1E,0x00,0x00,0x00,0x7C,0xFE,0xBA,0x82,0x82,0x7C,0x00
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x3E,0x63,0x7F,0x63,0x63,0x00,0x00
+.db 0x00,0x7E,0x63,0x7E,0x63,0x7E,0x00,0x00,0x00,0x3F,0x60,0x60,0x60,0x3F,0x00,0x00
+.db 0x00,0x7E,0x63,0x63,0x63,0x7E,0x00,0x00,0x00,0x7F,0x60,0x7C,0x60,0x7F,0x00,0x00
+.db 0x00,0x7F,0x60,0x7C,0x60,0x60,0x00,0x00,0x00,0x3F,0x60,0x67,0x63,0x3F,0x00,0x00
+.db 0x00,0x63,0x63,0x7F,0x63,0x63,0x00,0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x1E,0x00,0x00
+.db 0x00,0x1E,0x0C,0x0C,0x6C,0x38,0x00,0x00,0x00,0x63,0x66,0x7C,0x66,0x63,0x00,0x00
+.db 0x00,0x60,0x60,0x60,0x60,0x7F,0x00,0x00,0x00,0x63,0x77,0x7F,0x6B,0x63,0x00,0x00
+.db 0x00,0x63,0x73,0x7B,0x6F,0x67,0x00,0x00,0x00,0x3E,0x63,0x63,0x63,0x3E,0x00,0x00
+.db 0x00,0x7E,0x63,0x63,0x7E,0x60,0x00,0x00,0x00,0x3E,0x63,0x6B,0x66,0x3D,0x00,0x00
+.db 0x00,0x7E,0x63,0x63,0x7E,0x63,0x00,0x00,0x00,0x3F,0x60,0x3E,0x03,0x7E,0x00,0x00
+.db 0x00,0x7E,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x3E,0x00,0x00
+.db 0x00,0x63,0x63,0x63,0x36,0x1C,0x00,0x00,0x00,0x63,0x6B,0x7F,0x77,0x63,0x00,0x00
+.db 0x00,0x63,0x36,0x1C,0x36,0x63,0x00,0x00,0x00,0x66,0x66,0x3C,0x18,0x18,0x00,0x00
+.db 0x00,0x7E,0x0C,0x18,0x30,0x7E,0x00,0x00,0x00,0x1C,0x11,0x18,0x10,0x1D,0x00,0x80
+.db 0x00,0xE6,0x08,0xC8,0x28,0xC6,0x00,0x00,0x00,0x72,0x46,0x72,0x42,0x47,0x00,0x80
+.db 0x00,0x76,0x41,0x72,0x44,0x47,0x00,0x80,0x00,0x76,0x41,0x72,0x41,0x46,0x00,0x80
+.db 0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF
+.db 0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0x07,0x07,0x07,0x00,0x00,0x07,0x07,0x07
+.db 0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xC3,0xE7,0xE7
+.db 0xE0,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0xE0,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
+.db 0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE7,0xE7,0xE7,0xE7,0xE7,0xE7,0xE7,0xE7
+.db 0xE7,0xE7,0xC3,0x00,0x00,0xFF,0xFF,0xFF,0xE7,0xE7,0xC7,0x07,0x07,0xC7,0xE7,0xE7
+.db 0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00
+.db 0xE0,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0xE7,0xE7,0xC7,0x07,0x07,0x07,0x07,0x07
+.db 0xE7,0xE7,0xE3,0xE0,0xE0,0xE3,0xE7,0xE7,0x00,0x00,0x00,0x00,0x00,0xC3,0xE7,0xE7
+.db 0xE0,0xE0,0xC0,0x00,0x00,0xFF,0xFF,0xFF,0xE7,0xE7,0xC3,0x00,0x00,0xC3,0xE7,0xE7
+.db 0x83,0x7D,0x7D,0x7D,0x7D,0x7D,0x83,0xFF,0x83,0x01,0x01,0x01,0x01,0x01,0x83,0xFF
+.db 0x83,0x01,0x01,0x01,0x01,0x01,0x83,0xFF,0x83,0x01,0x01,0x01,0x01,0x01,0x83,0xFF
+.db 0x83,0x01,0x01,0x01,0x01,0x01,0x83,0xFF,0x00,0x00,0x00,0x00,0x7C,0x38,0x10,0x00
+.db 0xFF,0x87,0x83,0x81,0x83,0x87,0xFF,0xFF,0x0C,0x14,0x64,0x64,0x64,0x14,0x0C,0x00
+.db 0x0C,0x14,0x64,0x64,0x64,0x14,0x0C,0x00,0x00,0x00,0x18,0x24,0x24,0x18,0x00,0x00
+.db 0xFF,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFF,0xFF,0xFF,0xE7,0xC3,0xC3,0xE7,0xFF,0xFF
+.db 0xFF,0x9F,0xE7,0xF9,0xFE,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x7F,0x9F,0xFF,0xFF
+.db 0x00,0x00,0x01,0x06,0x18,0x60,0x00,0x00,0x00,0x60,0x80,0x00,0x00,0x00,0x00,0x00
+.db 0x00,0x40,0x20,0x11,0x0A,0x04,0x00,0x00,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00
+.db 0xFF,0xFB,0xF5,0xEE,0xDF,0xBF,0xFF,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x00,0x00
+.db 0xFF,0x81,0xBD,0xBD,0xFD,0xFC,0xFF,0x00,0xFF,0xFF,0xFF,0xEF,0xEF,0x0F,0xFF,0x00
+.db 0x00,0x18,0x24,0x42,0x01,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xEF,0xDF,0x3F,0xFF,0x00
+.db 0xFF,0x8F,0xF7,0xFB,0xFD,0xFE,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00
+.db 0xFF,0xBF,0xDF,0xE0,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0x3F,0xDF,0xEF,0xFF,0x00
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xE7,0xE7,0xC3,0x00,0x00,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xC0,0x00,0x00,0xC3,0xE7,0xE7
+.db 0xF8,0xF0,0xF0,0xF0,0xF0,0xF0,0xF8,0xFF,0x00,0x3C,0x22,0x22,0x22,0x3C,0x00,0xFF
+.db 0xC0,0x80,0x80,0x80,0x80,0x80,0xC0,0xFF,0x03,0x01,0x01,0x01,0x01,0x01,0x03,0xFF
+.db 0x00,0x18,0x00,0x38,0x18,0x3C,0x00,0x00,0x80,0x80,0x80,0xBE,0x80,0x80,0x80,0xFF
+.db 0x80,0x88,0x88,0xBE,0x88,0x88,0x80,0xFF,0x80,0x80,0xBE,0x9C,0x88,0x80,0x80,0xFF
+.db 0x80,0xBE,0x88,0x80,0x88,0x9C,0x80,0xFF,0x7F,0x80,0x80,0x80,0x80,0x80,0x7F,0xFF
+.db 0xFE,0x81,0x81,0x81,0x81,0x81,0xFE,0xFF,0xFF,0xAB,0xAB,0xAB,0xAB,0xFF,0xFF,0xFF
+.db 0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x1F,0x00,0x03,0x0F,0x7F,0xFF,0xFF,0xFF,0xFF
+.db 0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+.db 0x00,0xC0,0xF0,0xFE,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF8
+.db 0x00,0x00,0x00,0x01,0x01,0x03,0x07,0x07,0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+.db 0x00,0x00,0x00,0x80,0x80,0xC0,0xE0,0xE0,0x0F,0x1F,0x1F,0x1F,0x3F,0x3F,0x7F,0x7F
+.db 0xF0,0xF8,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+.db 0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE
+.db 0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x1F,0x0F,0xFE,0xFE,0xFC,0xFC,0xF8,0xF8,0xF8,0xF0
+.db 0x07,0x07,0x03,0x01,0x01,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xE0,0xE0,0xC0,0x80,0x80,0x00,0x00,0x00
+.db 0x1F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x7F,0x0F,0x03,0x00
+.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC
+.db 0xFF,0xFF,0xFF,0xFF,0xFE,0xF0,0xC0,0x00,0xF8,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+
+; color data BANK0
+; tiles: 0>255
+; RLE compressed - Original size:2048 - RLE size:355
+TILESET_col_B0:
+.db 0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE
+.db 0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE
+.db 0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE,0x07,0x2F,0x01,0xEE
+.db 0x18,0xE4,0x28,0x4E,0x07,0xF4,0x01,0xFE,0x07,0x84,0x01,0x8E,0x07,0xF4,0x01,0xFE
+.db 0x07,0xF4,0x01,0xFE,0x10,0x4E,0x10,0xE1,0x10,0x51,0x10,0xE1,0x08,0xED,0xFF,0xE1
+.db 0xF9,0xE1,0xD8,0xED,0x08,0xDE,0x10,0xED,0x10,0xD1,0x07,0xF4,0x01,0xE4,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0xFE,0x07,0xF4
+.db 0x01,0xFE,0x07,0xF4,0x01,0xFE,0x06,0x74,0x01,0xE4,0x01,0xEE,0x07,0x74,0x01,0x7E
+.db 0x06,0x74,0x01,0xE4,0x01,0xEE,0x06,0x74,0x01,0xE4,0x01,0xEE,0x06,0x74,0x01,0xE4
+.db 0x01,0xEE,0xA0,0xE5,0x08,0x14,0x08,0x1C,0x08,0x18,0x08,0x17,0x08,0x1F,0x08,0x71
+.db 0x08,0xE8,0x08,0xFE,0x08,0x2E,0x08,0x1E,0x08,0xEC,0x08,0xE9,0x07,0xF4,0x01,0xEE
+.db 0x07,0xF4,0x01,0xE4,0x07,0x4F,0x01,0x4E,0x07,0x4F,0x01,0x4E,0x07,0x4F,0x01,0xEE
+.db 0x07,0x4F,0x01,0x1E,0x07,0xF4,0x01,0xFE,0x07,0x4F,0x01,0x1E,0x07,0xF4,0x01,0xFE
+.db 0x07,0xF4,0x01,0xFE,0x07,0x4F,0x01,0x4E,0x07,0xF4,0x01,0xFE,0x07,0xF4,0x01,0x1E
+.db 0x07,0x4F,0x01,0x1E,0x07,0xF4,0x01,0x1E,0x07,0xF4,0x01,0x1E,0x08,0xFE,0x18,0xE5
+.db 0x08,0xE4,0x07,0x84,0x11,0xE4,0x07,0xF4,0x01,0xFE,0x20,0xE4,0x01,0x15,0x05,0x1C
+.db 0x01,0x15,0x01,0xE5,0x01,0x15,0x05,0x18,0x01,0x15,0x01,0xE5,0x07,0x15,0x01,0xE5
+.db 0xFF,0x61,0x00
+
+
+__endasm;
+}
+
+
+
+// set sprites data in vram
+void setSprites()
+{
+__asm
+ ld bc,#32*8 ;32* num sprites
+ ld hl,#SPRITES_DATA
+ ld de,#BASE14
+ call 0x005C
+
+ ret
+
+
+SPRITES_DATA:
+; 0
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
+.db 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80
+.db 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+; 1
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03
+.db 0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0
+.db 0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00
+; 2
+.db 0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07
+.db 0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0
+.db 0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00
+; 3
+.db 0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x0F
+.db 0x0F,0x0F,0x07,0x03,0x00,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x00,0xC0,0xE0,0xF0,0xF0
+.db 0xF0,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00
+; 4
+.db 0x00,0x00,0x00,0x01,0x07,0x0F,0x0F,0x1F
+.db 0x1F,0x0F,0x0F,0x07,0x01,0x00,0x00,0x00
+.db 0x00,0x00,0x00,0x80,0xE0,0xF0,0xF0,0xF8
+.db 0xF8,0xF0,0xF0,0xE0,0x80,0x00,0x00,0x00
+; 5
+.db 0x00,0x00,0x03,0x0F,0x1F,0x1F,0x3F,0x3F
+.db 0x3F,0x3F,0x1F,0x1F,0x0F,0x03,0x00,0x00
+.db 0x00,0x00,0xC0,0xF0,0xF8,0xF8,0xFC,0xFC
+.db 0xFC,0xFC,0xF8,0xF8,0xF0,0xC0,0x00,0x00
+; 6
+.db 0x00,0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F
+.db 0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00
+.db 0x00,0xC0,0xF0,0xF8,0xFC,0xFC,0xFE,0xFE
+.db 0xFE,0xFE,0xFC,0xFC,0xF8,0xF0,0xC0,0x00
+; 7
+.db 0x07,0x1F,0x3F,0x7F,0x7F,0xFF,0xFF,0xFF
+.db 0xFF,0xFF,0xFF,0x7F,0x7F,0x3F,0x1F,0x07
+.db 0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF
+.db 0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0
+
+__endasm;
+}
+
+
+
+
+// pantalla principal
+void setMainScr()
+{
+__asm
+
+ ld hl,#SCR01
+ ld de,#BASE10
+ jp unRLE2VR
+
+
+; tiles screen
+; VRAM address= 1800h
+; size=0300h
+; start x=0 y=0
+; end x=31 y=23
+; RLE compressed - Original size:768 - RLE size:521
+SCR01:
+.db 0x01,0xA0,0x0A,0xA1,0x01,0xA2,0x10,0xEF,0x01,0x1A,0x01,0x1B,0x01,0x1C,0x01,0x1D
+.db 0x01,0xA7,0x01,0x73,0x01,0x6F,0x01,0x6E,0x01,0x67,0x06,0x20,0x01,0xA8,0x14,0xEF
+.db 0x01,0xA7,0x01,0x20,0x01,0x54,0x01,0x45,0x01,0x4D,0x01,0x50,0x01,0x4F,0x01,0x20
+.db 0x01,0x0A,0x01,0xD9,0x01,0xDA,0x01,0xA8,0x14,0xEF,0x01,0xA7,0x0A,0x20,0x01,0xA8
+.db 0x14,0xEF,0x01,0xA7,0x03,0x20,0x01,0xD4,0x01,0x9D,0x01,0x80,0x01,0x92,0x01,0x8E
+.db 0x01,0x84,0x01,0xD7,0x01,0xA8,0x14,0xEF,0x01,0xA3,0x0A,0xA4,0x01,0xA6,0x14,0xEF
+.db 0x01,0xA7,0x01,0x64,0x01,0x72,0x01,0x75,0x01,0x6D,0x01,0x73,0x02,0x20,0x01,0x0F
+.db 0x01,0x12,0x01,0xBC,0x01,0xA8,0x14,0xEF,0x01,0xA7,0x0A,0x20,0x01,0xA8,0x07,0xEF
+.db 0x01,0xE0,0x01,0xE1,0x01,0xE2,0x01,0xE3,0x01,0xE4,0x01,0xE5,0x07,0xEF,0x01,0xA7
+.db 0x01,0x20,0x01,0x43,0x01,0x41,0x01,0x53,0x01,0x49,0x01,0x4F,0x02,0x20,0x01,0xDF
+.db 0x01,0xDE,0x01,0xA8,0x06,0xEF,0x01,0xE6,0x01,0xE7,0x04,0xE8,0x01,0xE9,0x01,0xEA
+.db 0x06,0xEF,0x01,0xA7,0x0A,0x20,0x01,0xA8,0x06,0xEF,0x01,0xEB,0x06,0xE8,0x01,0xEC
+.db 0x06,0xEF,0x01,0xA7,0x03,0x20,0x01,0xD4,0x01,0x9E,0x01,0x80,0x01,0x92,0x01,0x8E
+.db 0x01,0x84,0x01,0xD7,0x01,0xA8,0x06,0xEF,0x01,0xED,0x06,0xE8,0x01,0xEE,0x06,0xEF
+.db 0x01,0xA3,0x0A,0xA4,0x01,0xA6,0x06,0xEF,0x01,0xF0,0x06,0xE8,0x01,0xF1,0x06,0xEF
+.db 0x01,0xA7,0x01,0x74,0x01,0x6F,0x01,0x6E,0x01,0x65,0x01,0x18,0x01,0x19,0x01,0x20
+.db 0x01,0x0F,0x01,0x13,0x01,0xBC,0x01,0xA8,0x06,0xEF,0x01,0xF2,0x06,0xE8,0x01,0xF3
+.db 0x06,0xEF,0x01,0xA7,0x01,0x20,0x01,0x41,0x01,0x2B,0x01,0x42,0x04,0x20,0x01,0xDF
+.db 0x01,0xDE,0x01,0xA8,0x06,0xEF,0x01,0xF4,0x01,0xF5,0x04,0xE8,0x01,0xF6,0x01,0xF7
+.db 0x06,0xEF,0x01,0xA7,0x01,0x20,0x01,0x4F,0x01,0x53,0x01,0x45,0x01,0x54,0x03,0x0A
+.db 0x01,0xD9,0x01,0xDA,0x01,0xA8,0x07,0xEF,0x01,0xF8,0x01,0xF9,0x01,0xFA,0x01,0xFB
+.db 0x01,0xFC,0x01,0xFD,0x07,0xEF,0x01,0xA7,0x0A,0x20,0x01,0xA8,0x14,0xEF,0x01,0xA7
+.db 0x01,0x20,0x01,0x45,0x01,0x4E,0x01,0x56,0x01,0x20,0x02,0xD0,0x01,0x0A,0x01,0xD9
+.db 0x01,0xDA,0x01,0xA8,0x14,0xEF,0x01,0xA7,0x01,0x20,0x01,0x53,0x01,0x50,0x02,0x45
+.db 0x01,0x44,0x01,0x20,0x01,0x0A,0x01,0xD9,0x01,0xDA,0x01,0xA8,0x14,0xEF,0x01,0xA7
+.db 0x01,0x20,0x01,0x4C,0x02,0x4F,0x01,0x50,0x03,0x20,0x01,0xDF,0x01,0xDE,0x01,0xA8
+.db 0x14,0xEF,0x01,0xA7,0x0A,0x20,0x01,0xA8,0x14,0xEF,0x01,0xA7,0x01,0x20,0x01,0x4F
+.db 0x01,0x43,0x01,0x54,0x01,0x41,0x01,0x56,0x01,0x45,0x01,0x0A,0x01,0xD9,0x01,0xDA
+.db 0x01,0xA8,0x14,0xEF,0x01,0xA7,0x01,0x20,0x01,0x55,0x01,0x50,0x01,0x2F,0x01,0x44
+.db 0x01,0x4F,0x01,0x57,0x01,0x4E,0x01,0xD9,0x01,0xDA,0x01,0xA8,0x14,0xEF,0x01,0xA7
+.db 0x03,0x20,0x01,0xD4,0x01,0x9F,0x01,0x80,0x01,0x92,0x01,0x8E,0x01,0x84,0x01,0xD7
+.db 0x01,0xA8,0x01,0xEF,0x01,0x7E,0x10,0xB4,0x02,0xEF,0x01,0xAC,0x0A,0xAD,0x01,0xAE
+.db 0x01,0xEF,0x01,0x7F,0x10,0xB4,0x02,0xEF,0x00
+
+
+__endasm;
+}
+
+
+
+
+// vuelca desde una area de la RAM (PSG_RAM),
+// los valores de los registros del PSG
+// a tres diferentes chips (AY interno, AY Pazos y SCC)
+void play()
+{
+__asm
+ ld HL,#PSG_RAM ; direccion de memoria del buffer
+ ld B,#13 ; numero de registros
+
+ ld A,(#PLAY_HARDW) ;//indica que chip utiliza (0=AY interno, 1=AY pazos)
+ cp #0
+ jr NZ,MFR_CPY
+
+ ;PSG intern
+ xor A
+ ld C,#0xA1
+ILOOP:
+ out (#0xA0),A
+ inc A
+ outi
+ JR NZ,ILOOP
+ ret
+
+MFR_CPY:
+ cp #1
+ jr NZ,SCC_CPY
+
+ ;MEGAFLASHROM PSG
+ xor A
+ ld C,#0x11
+MLOOP:
+ out (#0x10),A
+ inc A
+ outi
+ JR NZ,MLOOP
+ ret
+
+SCC_CPY:
+ ;SCC
+ ret
+
+__endasm;
+}
+
+
+// genera un valor aleatorio de 8 bits y le aplica una máscara
+// necesita de un byte en la RAM (SEED)
+byte Rnd(char value)
+{
+value;
+__asm
+ ld C,4(ix) ;recoge el valor de la mascara
+
+ ld A,R ;
+ ld B,A
+
+ ld A,(SEED)
+ SRA A
+
+ add A,B
+ ;add A,A
+
+ ld B,A
+
+ ld A,R ;
+ add A,B
+
+ inc a
+
+ ld (SEED),A
+
+ AND C ;aplica la mascara
+
+
+ ld L,A
+__endasm;
+}
+
+
+void pressKey()
+{
+__asm
+ call #0x009F ;CHGET
+__endasm;
+}
+
+
+// llena una area de la RAM con un valor
+void fillRAM(uint address, int size, byte value)
+{
+address;value;size;
+
+__asm
+ ld L, 4(ix) ; HL direccion de origen
+ ld H, 5(ix)
+
+ ld C, 6(ix) ; DE num de bytes a copiar
+ ld B, 7(ix)
+
+ ld A, 8(ix) ; value
+
+ dec BC
+
+ ld D,H
+ ld E,L
+
+ inc DE
+
+ ld (HL),A
+ ldir
+
+__endasm;
+}
+
+
+
+// HL > DATA ADDR
+// DE > VRAM ADDR
+// descompresor RLE a VRAM
+void unRLE2VRAM()
+{
+__asm
+unRLE2VR:
+ ; direccion de VRAM (DE)
+ in A,(0x99)
+ di
+ ld A,E
+ out (0x99),A
+ ld A,D
+ add A,#0x40
+ out (0x99),A
+ ei
+
+getCMD: ;mira byte de instruccion 1-255 repeticion
+ ld A,(HL)
+ cp #0 ;si es 0 es fin
+ ret Z ;sale de la funcion
+
+ inc HL
+ ld B,A ;numero de repeticiones
+
+ ld A,(HL) ;recoge el valor
+
+RLE_bucle:
+ out (0x98),A
+ nop
+ nop
+ djnz RLE_bucle
+
+ inc HL
+
+ jr getCMD
+
+__endasm;
+}
+
+
+// ===========================================================================
+// 16-bit Integer to ASCII (decimal)
+// by baze
+// Input: HL = number to convert, DE = location of ASCII string
+// Output: ASCII string at (DE)
+// ===========================================================================
+void Num2Dec16(int aNumber, char *address)
+{
+ aNumber;
+ address;
+__asm
+ ld l,4(ix)
+ ld h,5(ix)
+
+ ld e,6(ix)
+ ld d,7(ix)
+
+ ld bc,#-10000
+ call $Num1
+ ld bc,#-1000
+ call $Num1
+ ld bc,#-100
+ call $Num1
+ ld c,#-10
+ call $Num1
+ ld c,b
+ call $Num1
+ jr $Num3
+$Num1:
+ ld a,#-1 ;ASCII-1 47
+$Num2:
+ inc a
+ add hl,bc
+ jr c,$Num2
+ sbc hl,bc
+ ld (de),a
+ inc de
+ ret
+$Num3:
+
+__endasm;
+}
+
+
+// genera un patron de ritmo de forma aleatoria
+void genDrumPattern()
+{
+ char hits;
+ char kicks;
+ char snares;
+ char conta=0;
+ byte increment=0;
+ uint vaddr =0x1aee;
+
+ char i;
+
+ for(i=0;i<16;i++) drum_pattern[i]=0;
+
+ hits=Rnd(3);
+ if(hits>0)
+ {
+ //hits++;
+ do{
+ conta+=hits;
+ if(conta<16) drum_pattern[conta]=3;
+ }while(conta<16);
+ }
+
+ conta=0;
+ kicks=Rnd(3)*2;
+ if(kicks>0)
+ {
+ do{
+ drum_pattern[conta]=1;
+ conta+=kicks;
+ }while(conta<16);
+ }
+
+ conta=0;
+ snares=Rnd(3)*4;
+ if(snares>0)
+ {
+ do{
+ conta+=snares;
+ if(conta<16) drum_pattern[conta]=2;
+ }while(conta<16);
+ }
+
+ for (i=0;i<16;i++) vpoke(vaddr++,drum_pattern[i]+180);
+
+}
+
+
+
+// genera un patron de tono de forma aleatoria
+void genTonePattern()
+{
+ byte type;
+ byte value;
+ byte conta=0;
+ byte increment=0;
+ uint vaddr =0x1aCe;
+
+ byte i;
+
+ for(i=0;i<16;i++) tone_pattern[i]=0;
+
+ type=Rnd(3)+1;
+ if (type==1) increment=0;
+ if (type==2) increment=4;
+ if (type>2) increment=2;
+
+ //vprintNumber(20,1, type, 3); //test
+ //vprintNumber(24,1, increment, 3);
+
+ type++;
+ for(i=1;i11) value=0;
+ tone_pattern[conta]=value+1;
+ conta=conta+increment;
+ }
+ for(i=0;i<8;i++)
+ {
+ tone_pattern[i+8]=tone_pattern[i];
+ }
+
+ for (i=0;i<16;i++){
+ if(tone_pattern[i]==0) vpoke(vaddr++,180);
+ else vpoke(vaddr++,184);
+ }
+ return;
+}
+
+
+// sube una nota el patron de tono
+void upNotePattern()
+{
+ char i;
+ byte value;
+
+ for(i=0;i<16;i++)
+ {
+ value = tone_pattern[i];
+ if(value>0 && value<96) tone_pattern[i]=value+1;
+ }
+
+ return;
+}
+
+
+// baja una nota el patron de tono
+void downNotePattern()
+{
+ char i;
+ byte value;
+
+ for(i=0;i<16;i++)
+ {
+ value = tone_pattern[i];
+ if(value>1) tone_pattern[i]=value-1;
+ }
+
+ return;
+}
+
+
+
+// proporciona la frecuencia a partir de un numero de nota
+// A=num de nota (0>96) HL=valor freq
+int getFreq(byte value) //__naked
+{
+value;
+__asm
+
+ //push IX
+
+ ld A,4(IX)
+
+;GETFREQ:
+ SLA A ; x2 (rotacion izquierda sin acarreo)
+ ld D,#0
+ ld E,A
+ ld IY,#VNOTAS
+ add IY,DE
+
+ ld L,(IY)
+ ld H,1(IY)
+
+ pop IX
+ ret
+
+VNOTAS:
+ .dw 0
+ ; Octava 0 (0)
+ .dw 0x0D5D,0x0C9C,0x0BE7,0x0B3C,0x0A9B,0x0A02,0x0973,0x08EB,0x086B,0x07F2,0x0780,0x0714
+ ; Octava 1 (24)
+ .dw 0x06AE,0x064E,0x05F4,0x059E,0x054D,0x0501,0x04B9,0x0475,0x0435,0x03F9,0x03C0,0x038A
+ ; Octava 2 (48)
+ .dw 0x0357,0x0327,0x02FA,0x02CF,0x02AF,0x0281,0x025D,0x023B,0x021B,0x01FC,0x01E0,0x01C5
+ ; Octava 3 (72)
+ .dw 0x01AC,0x0194,0x017D,0x0168,0x0153,0x0140,0x012E,0x011D,0x010D,0x00FE,0x00F0,0x00E2
+ ; Octava 4 (96)
+ .dw 0x00D6,0x00CA,0x00BE,0x00B4,0x00AA,0x00A0,0x0097,0x008F,0x0087,0x007F,0x0078,0x0071
+ ; Octava 5 (120)
+ .dw 0x006B,0x0065,0x005F,0x005A,0x0055,0x0050,0x004C,0x0047,0x0043,0x0040,0x003B,0x0039
+ ; Octava 6 (144)
+ .dw 0x0035,0x0032,0x0030,0x002D,0x002A,0x0028,0x0026,0x0024,0x0022,0x0020,0x001E,0x001C
+ ; Octava 7 (168)
+ .dw 0x001B,0x0019,0x0018,0x0016,0x0015,0x0014,0x0013,0x0012,0x0011,0x0010,0x000F,0x000E
+
+
+
+
+ ;.db 0,0 ;valor nulo
+ ; Octava 0 (0)
+ ;.db 0x5D,0x0D,0x9C,0x0C,0xE7,0x0B,0x3C,0x0B,0x9B,0x0A,0x02,0x0A,0x73,0x09,0xEB,0x08,0x6B,0x08,0xF2,0x07,0x80,0x07,0x14,0x07
+ ; Octava 1 (24)
+ ;.db 0xAE,0x06,0x4E,0x06,0xF4,0x05,0x9E,0x05,0x4D,0x05,0x01,0x05,0xB9,0x04,0x75,0x04,0x35,0x04,0xF9,0x03,0xC0,0x03,0x8A,0x03
+ ; Octava 2 (48)
+ ;.db 0x57,0x03,0x27,0x03,0xFA,0x02,0xCF,0x02,0xAF,0x02,0x81,0x02,0x5D,0x02,0x3B,0x02,0x1B,0x02,0xFC,0x01,0xE0,0x01,0xC5,0x01
+ ; Octava 3 (72)
+ ;.db 0xAC,0x01,0x94,0x01,0x7D,0x01,0x68,0x01,0x53,0x01,0x40,0x01,0x2E,0x01,0x1D,0x01,0x0D,0x01,0xFE,0x00,0xF0,0x00,0xE2,0x00
+ ; Octava 4 (96)
+ ;.db 0xD6,0x00,0xCA,0x00,0xBE,0x00,0xB4,0x00,0xAA,0x00,0xA0,0x00,0x97,0x00,0x8F,0x00,0x87,0x00,0x7F,0x00,0x78,0x00,0x71,0x00
+ ; Octava 5 (120)
+ ;.db 0x6B,0x00,0x65,0x00,0x5F,0x00,0x5A,0x00,0x55,0x00,0x50,0x00,0x4C,0x00,0x47,0x00,0x43,0x00,0x40,0x00,0x3B,0x00,0x39,0x00
+ ; Octava 6 (144)
+ ;.db 0x35,0x00,0x32,0x00,0x30,0x00,0x2D,0x00,0x2A,0x00,0x28,0x00,0x26,0x00,0x24,0x00,0x22,0x00,0x20,0x00,0x1E,0x00,0x1C,0x00
+ ; Octava 7 (168)
+ ;.db 0x1B,0x00,0x19,0x00,0x18,0x00,0x16,0x00,0x15,0x00,0x14,0x00,0x13,0x00,0x12,0x00,0x11,0x00,0x10,0x00,0x0F,0x00,0x0E,0x00
+
+__endasm;
+}
+
+
+// ===========================================================================
+// muestra un numero
+// posx - numero de columna (0 a 31)
+// posy - numero de fila (0 a 23)
+// aNumber (uint) - valor
+// aLength (byte) - numero de cifras
+// ===========================================================================
+void vprintNumber(byte posx, byte posy, uint aNumber, byte aLength)
+{
+ byte pos=5;
+ uint tiladdre=0;
+
+ char strBuff[5];
+
+ Num2Dec16(aNumber, strBuff);
+
+ // proporciona la direccion de la VRAM a partir de una posicion
+ tiladdre = getVAddressByPosition(posx, posy);
+
+ //coloca el puntero en la posicion donde se ha de empezar a mostrar
+ pos = 5-aLength;
+
+ // muestra el numero en la pantalla
+ while (aLength-->0){ vpoke(tiladdre++,strBuff[pos++]);}
+}
+
+
+
+// muestra un control tipo switch (interruptor)
+void switcher(uint vaddr, boolean value)
+{
+ if(value==true)
+ {
+ vpoke(vaddr++,221);
+ vpoke(vaddr,223);
+ }else{
+ vpoke(vaddr++,223);
+ vpoke(vaddr,222);
+ }
+ return;
+}
+
+
+// muestra el valor de la envolvente
+void showEnv(char value)
+{
+ vprintNumber(8,16, value, 3);
+ value=value*2+192;
+ vpoke(0x1A06,value++);
+ vpoke(0x1A07,value++);
+}
+
+
+// muestra el indicador de activación de canal de audio (altavoz)
+void showSpeaker(uint vaddr, boolean value)
+{
+ if(value==true) vpoke(vaddr,187);
+ else vpoke(vaddr,188);
+
+ return;
+}
+
+
+// cambia la paleta de colores del logo (MSX2)
+void setMSX2logoPal()
+{
+__asm
+
+ ld hl,#PALETTE00
+ xor a
+ di
+ out (#0x99),a
+ ld a,#144
+ out (#0x99),a
+ ld bc,#0x209A
+ otir
+ ei
+ ret
+
+; Default Palette
+; RB,G
+PALETTE00:
+.db 0x00,0x00
+.db 0x00,0x00
+.db 0x22,0x05
+.db 0x22,0x06
+.db 0x25,0x02
+.db 0x33,0x03
+.db 0x61,0x01
+.db 0x07,0x06
+.db 0x62,0x02
+.db 0x73,0x03
+.db 0x63,0x06
+.db 0x64,0x06
+.db 0x11,0x04
+.db 0x55,0x03
+.db 0x66,0x06
+.db 0x77,0x07
+
+__endasm;
+}
+
+
+// cambia la paleta de colores (MSX2)
+void setMSX2Palette()
+{
+__asm
+
+ ld hl,#PALETTE01
+ xor a
+ di
+ out (#0x99),a
+ ld a,#144
+ out (#0x99),a
+ ld bc,#0x209A
+ otir
+ ei
+ ret
+
+; alanRandoms
+; RB,G
+PALETTE01:
+.db 0x00,0x00
+.db 0x00,0x00
+.db 0x44,0x04
+.db 0x32,0x07
+.db 0x25,0x02
+.db 0x37,0x03
+.db 0x61,0x01
+.db 0x27,0x06
+.db 0x71,0x01
+.db 0x73,0x03
+.db 0x60,0x06
+.db 0x74,0x07
+.db 0x00,0x05
+.db 0x65,0x01
+.db 0x66,0x06
+.db 0x77,0x07
+
+__endasm;
+}
\ No newline at end of file