F14 - Forever young. Released at Forever 14
git-svn-id: svn://localhost/thomson@45 85ae3b6b-dc8f-4344-a89d-598714f2e4e5
diff --git a/code/C/F14/LOGO01.CRU b/code/C/F14/LOGO01.CRU
new file mode 100644
index 0000000..efe8516
--- /dev/null
+++ b/code/C/F14/LOGO01.CRU
Binary files differ
diff --git a/code/C/F14/LOGO03.CRU b/code/C/F14/LOGO03.CRU
new file mode 100644
index 0000000..52d66b4
--- /dev/null
+++ b/code/C/F14/LOGO03.CRU
Binary files differ
diff --git a/code/C/F14/MO5.script b/code/C/F14/MO5.script
new file mode 100644
index 0000000..7467f40
--- /dev/null
+++ b/code/C/F14/MO5.script
@@ -0,0 +1,9 @@
+section hibyte load 3000
+section .text.dp2
+section .text.dp load 3200
+section .text.startup
+section .text
+section *,!bss
+section *,bss
+
+entry _main
diff --git a/code/C/F14/MUSEUM01.CRU b/code/C/F14/MUSEUM01.CRU
new file mode 100644
index 0000000..cf0b152
--- /dev/null
+++ b/code/C/F14/MUSEUM01.CRU
Binary files differ
diff --git a/code/C/F14/MUSEUM02.CRU b/code/C/F14/MUSEUM02.CRU
new file mode 100644
index 0000000..40c4ee6
--- /dev/null
+++ b/code/C/F14/MUSEUM02.CRU
Binary files differ
diff --git a/code/C/F14/Makefile b/code/C/F14/Makefile
new file mode 100644
index 0000000..822f465
--- /dev/null
+++ b/code/C/F14/Makefile
@@ -0,0 +1,31 @@
+.SECONDARY:
+all: obj/main.K5
+
+CC=m6809-thomson-none-gcc
+CFLAGS=-O2 -fomit-frame-pointer -save-temps=obj -Wall -Werror -std=gnu99
+
+obj/main.bin:: obj/plasma_asm.o obj/plasma.o obj/twister.o obj/trig.o obj/picture.o obj/greetings.o obj/text.o obj/font_hs2.o obj/poiscaie.o obj/waves.o
+
+obj/BIGTHOM.PIC: BGCOLOR = 0
+
+obj/%.bin: obj/%.o
+ lwlink --decb --output=$@ --map=$@.map --script=MO5.script $^
+
+obj/trig.o: ../libdemo/trig.c
+ $(CC) $(CFLAGS) -I../F14 -c -o $@ $^
+
+###
+
+obj/%.PIC : %.png
+ png2mo5 $< $@ $(BGCOLOR)
+
+obj/%.o : %.c
+ $(CC) $(CFLAGS) -I. -c -o $@ $^
+
+obj/%.o: %.s
+ lwasm -9 -fobj -o$@ $^
+
+obj/%.K5: obj/%.bin
+ f2k5 $<
+ mv FILE.K5 $@
+
diff --git a/code/C/F14/POI01.CRU b/code/C/F14/POI01.CRU
new file mode 100644
index 0000000..0343664
--- /dev/null
+++ b/code/C/F14/POI01.CRU
Binary files differ
diff --git a/code/C/F14/POI03.CRU b/code/C/F14/POI03.CRU
new file mode 100644
index 0000000..beb23fe
--- /dev/null
+++ b/code/C/F14/POI03.CRU
Binary files differ
diff --git a/code/C/F14/THOM01.CRU b/code/C/F14/THOM01.CRU
new file mode 100644
index 0000000..9b543b1
--- /dev/null
+++ b/code/C/F14/THOM01.CRU
Binary files differ
diff --git a/code/C/F14/THOM02.CRU b/code/C/F14/THOM02.CRU
new file mode 100644
index 0000000..67f6db5
--- /dev/null
+++ b/code/C/F14/THOM02.CRU
Binary files differ
diff --git a/code/C/F14/TWI01.CRU b/code/C/F14/TWI01.CRU
new file mode 100644
index 0000000..221b9af
--- /dev/null
+++ b/code/C/F14/TWI01.CRU
Binary files differ
diff --git a/code/C/F14/TWI03.CRU b/code/C/F14/TWI03.CRU
new file mode 100644
index 0000000..81bde6d
--- /dev/null
+++ b/code/C/F14/TWI03.CRU
Binary files differ
diff --git a/code/C/F14/effect.h b/code/C/F14/effect.h
new file mode 100644
index 0000000..7e48337
--- /dev/null
+++ b/code/C/F14/effect.h
@@ -0,0 +1,19 @@
+#include <stdint.h>
+
+void init_P();
+
+void init_L();
+void draw_L(int frame);
+
+void init_T();
+void draw_T(int frame);
+
+void init_G();
+void draw_G(int frame);
+
+void init();
+void draw(int frame);
+
+extern uint8_t* screen;
+void forme(void);
+void couleur(void);
diff --git a/code/C/F14/font_hs2.c b/code/C/F14/font_hs2.c
new file mode 100644
index 0000000..966b4eb
--- /dev/null
+++ b/code/C/F14/font_hs2.c
@@ -0,0 +1,93 @@
+unsigned char font[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x0c, 0x00, 0x00,
+ 0x33, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x12, 0x3f, 0x12, 0x3f, 0x12, 0x00, 0x00,
+ 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x0c, 0x18, 0x18, 0x18, 0x0c, 0x06, 0x00,
+ 0x18, 0x0c, 0x06, 0x06, 0x06, 0x0c, 0x18, 0x00,
+ 0x00, 0x0c, 0x2d, 0x1e, 0x2d, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
+ 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00,
+ 0x3e, 0x63, 0x63, 0x63, 0x7f, 0x3e, 0x00, 0x00,
+ 0x1c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00,
+ 0x7e, 0x07, 0x3e, 0x60, 0x7f, 0x7f, 0x00, 0x00,
+ 0x7e, 0x03, 0x7f, 0x03, 0x7f, 0x7e, 0x00, 0x00,
+ 0x63, 0x63, 0x63, 0x3f, 0x03, 0x03, 0x00, 0x00,
+ 0x7f, 0x70, 0x7e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00, 0x00,
+ 0x60, 0x60, 0x60, 0x60, 0x7f, 0x3f, 0x00, 0x00,
+ 0x7e, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x00, 0x00,
+ 0x7e, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x00,
+ 0x3e, 0x63, 0x63, 0x63, 0x7f, 0x3e, 0x00, 0x00,
+ 0x7e, 0x63, 0x63, 0x7e, 0x60, 0x60, 0x00, 0x00,
+ 0x3e, 0x63, 0x63, 0x6b, 0x7f, 0x3e, 0x0c, 0x0c,
+ 0x7e, 0x63, 0x63, 0x7e, 0x63, 0x63, 0x00, 0x00,
+ 0x3f, 0x70, 0x3e, 0x03, 0x7f, 0x7e, 0x00, 0x00,
+ 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
+ 0x63, 0x63, 0x63, 0x63, 0x7f, 0x3e, 0x00, 0x00,
+ 0x63, 0x63, 0x63, 0x77, 0x3e, 0x1c, 0x00, 0x00,
+ 0x6b, 0x6b, 0x6b, 0x6b, 0x7e, 0x7c, 0x00, 0x00,
+ 0x63, 0x63, 0x3e, 0x63, 0x63, 0x63, 0x00, 0x00,
+ 0x63, 0x63, 0x3f, 0x03, 0x7f, 0x7e, 0x00, 0x00,
+ 0x7f, 0x07, 0x1c, 0x70, 0x7f, 0x7f, 0x00, 0x00,
+ 0x08, 0x68, 0x58, 0x66, 0x19, 0x06, 0x01, 0x00,
+ 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x00, 0x00,
+ 0x10, 0x16, 0x1e, 0x7e, 0xf8, 0xe0, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3f, 0x63, 0x63, 0x7f, 0x3f, 0x00, 0x00,
+ 0x60, 0x60, 0x7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 0x63, 0x00, 0x00,
+ 0x00, 0x63, 0x63, 0x63, 0x3f, 0x03, 0x03, 0x3e,
+ 0x00, 0x7F, 0x07, 0x1C, 0x70, 0x7F, 0x00, 0x00
+};
diff --git a/code/C/F14/greetings.c b/code/C/F14/greetings.c
new file mode 100644
index 0000000..bfb51a5
--- /dev/null
+++ b/code/C/F14/greetings.c
@@ -0,0 +1,259 @@
+#include "effect.h"
+#include "text.h"
+
+asm("\n"
+" .area .text \n"
+" INCLUDEBIN ../THOM02.CRU \n"
+"color_thom \n"
+" INCLUDEBIN ../THOM01.CRU \n"
+"forme_thom \n"
+);
+
+static int m = 0;
+static int chr = 0;
+
+void init_G()
+{
+ asm(" LDX #color_thom-1 \n"
+ " LDU #forme_thom-1 \n"
+ " LBSR decrunchpic \n"
+ :::"x","u","y");
+
+ couleur();
+
+ int x;
+
+ for(int y = 0; y <= 32; y++)
+ for(x = 10; x < 29; x++)
+ {
+ if (y > 8 || x < 28)
+ *(char*)((70 + y) * 40 + x) &= 0xF;
+ if (y > 8 || x > 11)
+ *(char*)((135 - y) * 40 + x) &= 0xF;
+ }
+
+ m = 0;
+ chr = 0;
+}
+
+static const char* const messages[] = {
+"This is the end of\n"
+"\n"
+" F-14\n"
+" \"Forever Young\"\n"
+"\n"
+" by\n"
+"\n"
+" SHINRA and JFF\0",
+// X X
+
+"Code:\n"
+" PulkoMandy/SHR\n"
+"\n"
+"Graphics:\n"
+" Exocet/JFF\n"
+"\n"
+"Music:\n"
+" PulkoMandy/SHR",
+// XX X
+
+
+"This demo is the\n"
+"result of 3 years\n"
+"of hard work...\n"
+"\n"
+"Coding the effects\n"
+"but also the tools\n"
+"for MO5 development\n",
+// XX X
+
+
+"\n"
+"The following tools\n"
+"were used (thanks!)\n"
+"\n"
+"GCC-6809\n"
+" by Eric Botcazou\n"
+" Brian Dominy\n"
+" William Astle\n",
+// XX X
+
+
+"lwtools\n"
+" by William Astle\n"
+"dcmo5\n"
+" by Daniel Coulom\n"
+"Exomizer 2\n"
+" by Magnus Lind\n"
+" Edouard Forler\n",
+// XX X
+
+
+"The following were\n"
+"developped for our\n"
+"very special needs\n"
+"\n"
+"CrO2, f2k5 and\n"
+"MEATracker\n"
+" by PulkoMandy",
+// XX X
+
+
+"png2mo5\n"
+" by Shinra Team\n"
+"\n"
+"\n"
+"GrafX2\n"
+" by Shinra Team\n"
+" Sunset Design",
+// XX X
+
+
+" We would also\n"
+" like to greet\n"
+"\n"
+"the Haiku project\n"
+" for Haiku\n"
+"TECGRAF\n"
+" for IUP and Lua",
+// XX X
+
+
+"\n"
+"the GNU project\n"
+" for GNU Make\n"
+"\n"
+"\n"
+"Bram Moleenar\n"
+" for Vim",
+// XX X
+
+
+"Of course, some\n"
+"greetings to the\n"
+"demoscene members\n"
+"(current and past)\n"
+"\n"
+"Mike/Zeroteam and\n"
+"the Forever team",
+// XX X
+
+
+"Sucres en Morceaux\n"
+"ARKOS BND FUTUR'S\n"
+" and the CPC Scene\n"
+"Dimension HCL PULS\n"
+" the Thomson guys\n"
+"Linefeed LFT AA-Grp\n"
+" elsewhere...\n",
+// XX X
+
+
+" See you next year\n"
+" at Forever!\n"
+" <=\n"
+" []\n"
+"\n"
+"(C) MMXIII SHR&JFF\n"
+"shinra.cpcscene.com\n"
+// XX X
+};
+
+int nextchar();
+int erase();
+
+void draw_G(int frame)
+{
+ static int state = 1;
+ forme();
+
+ // actually wait for a frame
+asm("\n"
+"waitvbl TST 0xA7E7 \n"
+" BPL waitvbl\n"
+"waitmore TST 0xA7E7 \n"
+" BMI waitmore\n"
+);
+
+ switch(state)
+ {
+ case 1:
+ state = erase();
+ break;
+ case 0:
+ if (frame & 0x3) return;
+ state = nextchar();
+ break;
+ default:
+ state = 0;
+ }
+}
+
+int nextchar()
+{
+ static int x = 10;
+ static int y = 70;
+
+ char c = messages[m][chr];
+
+ switch(c)
+ {
+ case 0:
+ {
+ x = 10;
+ y = 70;
+ chr = 0;
+
+ if (m > 10) {
+ *(volatile unsigned char*)(0xA7CF) = 255;
+ for(;;);
+ }
+ m++;
+
+ return 1;
+ }
+ case '\n':
+ {
+ x = 10;
+ y += 8;
+ chr++;
+ break;
+ }
+ case ' ':
+ {
+ x++;
+ chr++;
+ break;
+ }
+ default:
+ {
+ drawchar(c, x++, y);
+ chr++;
+ }
+ }
+
+ return 0;
+}
+
+int erase()
+{
+ static int y = 0;
+ int x;
+
+ for(x = 10; x < 29; x++)
+ {
+ if (y >= 8 || x < 28)
+ *(char*)((70 + y) * 40 + x) = 0;
+ if (y >= 8 || x > 11)
+ *(char*)((135 - y) * 40 + x) = 0;
+ }
+
+ y++;
+
+ if (y > 32) {
+ y = 0;
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/code/C/F14/main.c b/code/C/F14/main.c
new file mode 100644
index 0000000..39c982e
--- /dev/null
+++ b/code/C/F14/main.c
@@ -0,0 +1,190 @@
+#include "effect.h"
+#include "../libdemo/trig.h"
+
+uint8_t* screen = 0;
+
+enum timings
+{
+ WAVES = 300,
+ TWISTER = WAVES + 400,
+ POISCAIE = TWISTER + 200,
+ PLASMA = POISCAIE + 800
+};
+
+#define MEA_CMD *(volatile unsigned char*)(0xA7CF)
+#define MEA_DATA *(volatile unsigned char*)(0xA7CE)
+
+ static const unsigned char patterns[] =
+ {
+ 0,0,0,1,0,0,0,1,0,2,0,1,2,2,1,1
+ };
+
+ static const unsigned char music[] =
+ {
+
+// 0000
+ 0xFF, 0xD0, 0x87, 0x80, // A
+ 0xF0, 0xD0, 0x87, 0x80, // A
+ 0xF0, 0xD0, 0x87, 0x80, // A
+ 0xF0, 0xD5, 0xAF, 0x80, // D
+
+ 0xFF, 0xD0, 0x87, 0x80, // A
+ 0xF0, 0xD3, 0x9F, 0x80, // C
+ 0xF0, 0xD5, 0xAF, 0x80, // D
+ 0xF0, 0xD5, 0xAF, 0x80, // D
+// 0001
+ 0xFF, 0xD0, 0x87, 0x80, // A
+ 0xF1, 0xD0, 0x87, 0x80, // A
+ 0xF1, 0xD0, 0x87, 0x80, // A
+ 0xF1, 0xD5, 0xAF, 0x80, // D
+
+ 0xFF, 0xD0, 0x87, 0x80, // A
+ 0xF0, 0xD3, 0x9F, 0x80, // C
+ 0xF3, 0xD5, 0xAF, 0x89, // D
+ 0x00, 0xD3, 0x91, 0x80, // ---
+// 0002
+ 0xFF, 0xD3, 0x9F, 0x80, // C
+ 0xF1, 0xD3, 0x9F, 0x80, // C
+ 0xF1, 0xD3, 0x9F, 0x80, // C
+ 0xF1, 0xD5, 0xAF, 0x80, // D
+
+ 0xFF, 0xD0, 0x87, 0x80, // A
+ 0xF0, 0xD3, 0x9F, 0x80, // C
+ 0xF0, 0xD5, 0xAF, 0x86, // D
+ 0x00, 0xD3, 0x91, 0x80, // ---
+ };
+
+void p_music(void)
+{
+ static int i = 0;
+ static int pos = 0;
+ static int pat = 0;
+
+
+ i++;
+ if (i > 4) {
+ if ((pos & 0x3) == 0)
+ {
+ MEA_CMD = 16 + 12;
+ switch(patterns[pat]) {
+ case 0:
+ MEA_DATA = 220;
+ break;
+ case 1:
+ MEA_DATA = 131;
+ break;
+ case 2:
+ MEA_DATA = 147;
+ break;
+ default:
+ MEA_DATA = 0xFF;
+ break;
+ }
+ }
+
+ for (int j = 0; j < 4; j++)
+ {
+ MEA_DATA = music[(patterns[pat] * 8*4) | j | (pos<<2)];
+ }
+ i = 0;
+ pos ++;
+ if (pos >= 8)
+ {
+ pos = 0;
+
+ pat++;
+ if(pat >= sizeof(patterns)) pat = 0;
+ }
+ }
+
+}
+
+int main(void)
+{
+ int frame = 0;
+
+ asm(" ORCC #$50"); // Disable interrupts (cursor blink)
+
+ polysine();
+
+ // show SHR&JFF logo + ondulations
+ init_L();
+ for(;frame < WAVES;) {
+ p_music();
+ draw_L(frame++);
+ p_music();
+ frame++;
+ }
+
+ // TODO clear screen, put on some nice background for the twister
+ couleur();
+ for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++)
+ *i = 0;
+
+ // TWISTER !!!
+ init_T();
+ for(;frame < TWISTER;) {
+ p_music();
+ p_music();
+ draw_T(frame++);
+ }
+
+ // TODO clear color ram to some nice color while we prepare the picture
+ couleur();
+ for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++)
+ *i = 0;
+
+ // POISCAIE
+ init_P();
+ for(;frame < POISCAIE;) {
+ p_music();
+ asm("\n"
+"w TST 0xA7E7 \n"
+" BMI w \n"
+"q TST 0xA7E7 \n"
+" BPL q \n"
+ );
+ frame++;
+ }
+
+ // TODO, again, clear the the color ram while we setup the plasma
+ couleur();
+ for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++)
+ *i = 0;
+
+ init();
+ for(;frame < PLASMA;) {
+ p_music();
+ p_music();
+ p_music();
+ draw(frame++);
+ }
+
+ // TODO and finally, clear the picture to setup the greetings
+ couleur();
+ for(unsigned int* i = (unsigned int*)0; i < (unsigned int*)8000; i++)
+ *i = 0;
+
+ // note: may be interesting to darken the plasma colorpalette to nicely
+ // fade to black (or white), while the plasma is still moving
+ init_G();
+ for(;;) {
+ p_music();
+ draw_G(frame++);
+ }
+}
+
+// FIXME use libthomson !
+void forme(void)
+{
+ asm(" SWI \n"
+ " FCB 6"
+ );
+}
+
+void couleur(void)
+{
+ asm(" SWI \n"
+ " FCB 4"
+ );
+}
diff --git a/code/C/F14/picture.s b/code/C/F14/picture.s
new file mode 100644
index 0000000..cb6bcbd
--- /dev/null
+++ b/code/C/F14/picture.s
@@ -0,0 +1,41 @@
+ .module picture.s
+; .area .text
+
+; INCLUDEBIN POI01.CRU
+;forme
+; INCLUDEBIN POI03.CRU
+;couleur
+
+; .globl _main
+;_main
+; LDU #couleur-1
+; LDX #forme-1
+; LBRA decrunchpic
+
+ .area .text.dp
+
+ .globl exo2
+ INCLUDE ../../../../_TOOLS/exomizer206/rawdecrs/6809/exo2_final.asm
+ ; INPUT
+ ; X = PTR to FORME (last byte)
+ ; U = PTR to COULEUR (last byte)
+
+ .globl decrunchpic
+decrunchpic
+ PSHS A
+
+ LDA 0xA7C0
+ ORA #1
+ STA 0xA7C0
+
+ PULS A
+
+ LDY #8000
+ LBSR exo2
+
+ DEC 0xA7C0
+
+ TFR X,U
+ LDY #8000
+ LBRA exo2
+
diff --git a/code/C/F14/plasma.c b/code/C/F14/plasma.c
new file mode 100644
index 0000000..0326bc8
--- /dev/null
+++ b/code/C/F14/plasma.c
@@ -0,0 +1,99 @@
+#include "effect.h"
+
+#include "../libdemo/trig.h"
+
+uint8_t backbuffer[256];
+const uint8_t colors[] __attribute__((section("hibyte"))) = {
+ // ICE
+ 0x00, 0x04, 0x44, 0x4C, 0xCC, 0xC6, 0x66, 0x6E,
+ 0xEE, 0xE7, 0x77, 0x7D, 0xDD, 0xD5, 0x55, /*0x50,*/
+
+ // RAINBOW
+ /*0x55,*/ 0x54, 0x44, 0x46, 0x66, 0x62, 0x22, 0x20,
+ 0x00, 0x01, 0x11, 0x13, 0x33, 0x37, 0x77, /*0x75,*/
+
+ // WHITE
+ /*0x77,*/ 0x7D, 0xDD, 0xDC, 0xCC, 0xCE, 0xEE, 0xEA,
+ 0xAA, 0xA8, 0x88, 0x89, 0x99, 0x9B, 0xBB, /*0xB7,*/
+
+ // APPLES
+ /*0xBB,*/ 0xB7, 0x77, 0x79, 0x99, 0x91, 0x11, 0x10,
+ 0x00, 0x02, 0x22, 0x23, 0x33, 0x3A, 0xAA, 0xAB,
+
+ 0xBB, 0xB3, 0x33, 0x32, 0x22, 0x20,
+ // FIRE
+ /*
+ 0x11, 0x1F, 0xFF, 0xFD, 0xDD, 0xD9, 0x99, 0x9B,
+ 0xBB, 0xB3, 0x33, 0x39, 0x99, 0x9F, 0xFF, 0xF1,*/
+
+ 0x00, 0x04, 0x44, 0x4C, 0xCC, 0xC6, 0x66, 0x6E,
+ 0xEE, 0xE7, 0x77, 0x7D, 0xDD, 0xD5, 0x55, 0x54,
+ 0x44, 0x46, 0x66, 0x62, 0x22, 0x20, 0x00, 0x01,
+ 0x11, 0x13, 0x33, 0x37, 0x77, 0x7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D5, 0x55, 0x50
+};
+
+extern unsigned char SIN[256];
+
+static void decrunch()
+{
+ asm(
+ " LDX #color_plasma-1 \n"
+ " LDU #forme_plasma-1 \n"
+ " LBSR decrunchpic \n"
+ :::"x","u", "y");
+}
+
+void init()
+{
+ int x,y,v;
+
+// INIT ONCE
+ for(y = 0; y < 256; y++)
+ {
+ backbuffer[y] = (SIN[y] / 32);
+ }
+
+ polysine();
+
+// EACHTIME
+
+ decrunch();
+ forme();
+ v = 0x55;
+ for(y = 40 * 40; y < 139 * 40; y+=40)
+ {
+ for(x = 10; x < 30; x++)
+ screen[y + x] = v;
+ v ^= 0xFF; // or rotate
+ }
+ couleur();
+
+ asm(" LDA #_draw/256 \n"
+ " TFR A,DP \n"
+ ::: "a"
+ );
+}
+
diff --git a/code/C/F14/plasma_asm.s b/code/C/F14/plasma_asm.s
new file mode 100644
index 0000000..eb11fad
--- /dev/null
+++ b/code/C/F14/plasma_asm.s
@@ -0,0 +1,120 @@
+ .module plasma_asm.s
+ .area .text.dp2 # waiting for next LWTools release where we can easily align them all!
+
+_SIN EXTERN
+_screen EXTERN
+_colors EXTERN
+_backbuffer EXTERN
+
+ .globl _draw
+_draw:
+ ; Param: X = frame
+
+ ; Save registers to make the calling C code happy
+ pshs y,u
+ STS <spt+2
+
+ ; SYNC with display
+;w LDA 0xA7E7
+; BMI w
+
+ ; white border
+; INC 0xA7C0
+; INC 0xA7C0
+
+ ; #########################################
+ ; U2 = SIN[frame] + frame
+ ldb _SIN,x
+ abx
+ stx <u2-1
+
+ ; U5 = SIN + frame
+ inc <u5+3
+
+ ; U3 = 99 (current line)
+ ldb #50
+ stb <u3+1
+
+ ; U = Pointer to destination byte on screen
+ini ldu #1630
+L11:
+ ; U9 = U3 / 2 + U2 = line / 2 + frame + sin[frame]
+u3 ldb #00
+ ;asrb
+ addb <u2
+ stb <u9+1
+
+ ; U4 = U2 + *(U5+U13)
+ ldx <u5+2
+ ldb b,x
+ addb <u2
+ stb <u4+1
+
+ ; Y = 0
+ ldy #20
+L10:
+ ; U13 = U9 + SIN[frame+col]
+u5 ldb _SIN+256,y
+
+u9 addb #00
+ tfr d,s
+
+ ; B = U12*8 + U4
+ tfr y,d
+ aslb
+ aslb
+ ;aslb
+u4 addb #00
+
+ ; B = back[U13] + back[B]
+ ldx #_backbuffer+128
+ ldb b,x
+ addb _backbuffer,s
+
+ ; B = colors[B]
+fra ldx #_colors
+ ldb b,x
+
+ ; *(U10++) = B
+ ;stb 39,u
+ pshu b
+
+ leay ,-y
+ ; while(Y++ < 20);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ bne L10
+
+
+ ; U7 = U7 + 40
+ leau 100,u
+
+ ; U3--
+ dec <u3+1
+ ; while(U3 >= 0)
+ lbne L11
+
+ ldb ini+2
+ addb #40
+ cmpb #0x86
+ beq ok
+ inc <fra+2
+ subb #80
+ok stb ini+2
+
+; DEC 0xA7C0
+; DEC 0xA7C0
+ ; Restore stack and regs
+spt LDS #00
+ puls y,u,pc
+
+ RMB 1
+u2 RMB 1
+ ALIGN 256
+
+ .area .text
+
+ INCLUDEBIN MUSEUM02.CRU
+ .globl color_plasma
+color_plasma
+ INCLUDEBIN MUSEUM01.CRU
+ .globl forme_plasma
+forme_plasma
diff --git a/code/C/F14/poiscaie.c b/code/C/F14/poiscaie.c
new file mode 100644
index 0000000..625e5a4
--- /dev/null
+++ b/code/C/F14/poiscaie.c
@@ -0,0 +1,19 @@
+
+asm("\n"
+" .area .text \n"
+" INCLUDEBIN ../POI03.CRU \n"
+"color_poi \n"
+" INCLUDEBIN ../POI01.CRU \n"
+"forme_poi \n"
+);
+
+int init_P()
+{
+ asm(
+ " LDX #color_poi-1 \n"
+ " LDU #forme_poi-1 \n"
+ " LBSR decrunchpic \n"
+ :::"x","u", "y");
+
+ return 0;
+}
diff --git a/code/C/F14/res/BIGTHOM.png b/code/C/F14/res/BIGTHOM.png
new file mode 100644
index 0000000..6e4cfd0
--- /dev/null
+++ b/code/C/F14/res/BIGTHOM.png
Binary files differ
diff --git a/code/C/F14/res/LOGOS.png b/code/C/F14/res/LOGOS.png
new file mode 100644
index 0000000..0d10fbc
--- /dev/null
+++ b/code/C/F14/res/LOGOS.png
Binary files differ
diff --git a/code/C/F14/res/PLASMA.png b/code/C/F14/res/PLASMA.png
new file mode 100644
index 0000000..b30f9ca
--- /dev/null
+++ b/code/C/F14/res/PLASMA.png
Binary files differ
diff --git a/code/C/F14/res/TWISTER.png b/code/C/F14/res/TWISTER.png
new file mode 100644
index 0000000..7ece8a0
--- /dev/null
+++ b/code/C/F14/res/TWISTER.png
Binary files differ
diff --git a/code/C/F14/res/fontHS_2.gif b/code/C/F14/res/fontHS_2.gif
new file mode 100644
index 0000000..cc48353
--- /dev/null
+++ b/code/C/F14/res/fontHS_2.gif
Binary files differ
diff --git a/code/C/F14/res/fonths2.bin b/code/C/F14/res/fonths2.bin
new file mode 100644
index 0000000..382c999
--- /dev/null
+++ b/code/C/F14/res/fonths2.bin
Binary files differ
diff --git a/code/C/F14/res/greetings.gif b/code/C/F14/res/greetings.gif
new file mode 100644
index 0000000..24fade2
--- /dev/null
+++ b/code/C/F14/res/greetings.gif
Binary files differ
diff --git a/code/C/F14/res/poiscMO5.png b/code/C/F14/res/poiscMO5.png
new file mode 100644
index 0000000..e77fb8c
--- /dev/null
+++ b/code/C/F14/res/poiscMO5.png
Binary files differ
diff --git a/code/C/F14/stdint.h b/code/C/F14/stdint.h
new file mode 100644
index 0000000..a8dd5db
--- /dev/null
+++ b/code/C/F14/stdint.h
@@ -0,0 +1,3 @@
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+typedef unsigned int uint16_t;
diff --git a/code/C/F14/text.c b/code/C/F14/text.c
new file mode 100644
index 0000000..7daef60
--- /dev/null
+++ b/code/C/F14/text.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2013, Adrien Destugues <pulkomandy@pulkomandy.tk>
+ * Distributed under the terms of the MIT licence
+ *
+ * Text printing routines for F-14 (easily reusable...)
+ *
+ * A character is stored as 8 bytes
+ * This code assumes that the color RAM is set properly and does not modify it.
+ *
+ * Each char is stored as 8 bytes, they can be copied on the screen (no masking)
+ * To erase a char, just store 0s over the 8 bytes. Easy.
+ *
+ * TODO: optimize this ! Should be easy to get it way faster by using asm code...
+ */
+
+#include "text.h"
+
+extern uint8_t font[];
+
+/* x in bytes [0..39]
+ * y in pixel-lines [0..192]
+ */
+void drawchar(char c, uint8_t x, uint8_t y)
+{
+ uint8_t* ptr = &font[(c-32) * 8];
+ uint8_t* dest = (uint8_t*)(y * 40 + x);
+
+ *dest = *ptr++;
+ *(dest+40) = *ptr++;
+ *(dest+80) = *ptr++;
+ *(dest+120) = *ptr++;
+ *(dest+160) = *ptr++;
+ *(dest+200) = *ptr++;
+ *(dest+240) = *ptr++;
+ *(dest+280) = *ptr++;
+}
+
+void drawstring(const char* str, uint8_t x, uint8_t y)
+{
+ int inix = x;
+ while(*str != 0)
+ {
+ if(*str == '\n') {
+ x = inix;
+ y += 8;
+ str++;
+ continue;
+ }
+
+ drawchar(*str++, x++, y);
+ }
+}
diff --git a/code/C/F14/text.h b/code/C/F14/text.h
new file mode 100644
index 0000000..f5a816d
--- /dev/null
+++ b/code/C/F14/text.h
@@ -0,0 +1,4 @@
+#include "stdint.h"
+
+void drawchar(char c, uint8_t x, uint8_t y);
+void drawstring(const char* str, uint8_t x, uint8_t y);
diff --git a/code/C/F14/twister.c b/code/C/F14/twister.c
new file mode 100644
index 0000000..eda8da6
--- /dev/null
+++ b/code/C/F14/twister.c
@@ -0,0 +1,110 @@
+#include "effect.h"
+
+asm("\n"
+" .area .text \n"
+" INCLUDEBIN ../TWI03.CRU \n"
+"color_twi \n"
+" INCLUDEBIN ../TWI01.CRU \n"
+"forme_twi \n"
+);
+
+extern unsigned char SIN[256];
+
+uint8_t backbuffer[256*32];
+
+static void line(uint8_t x1, int y, uint8_t x2, char color)
+{
+ static const uint8_t start[] = {0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01};
+ static const uint8_t end[] = {0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF};
+ int x;
+ if(x1 > x2) return;
+ y *= 32;
+
+ x = start[x1 & 7] & color;
+ backbuffer[y + (x1>>3)] |= x;
+
+ for(x = (x1>>3) +1; x < x2>>3; x++)
+ backbuffer[y + x] = color;
+
+ x = end[x2 & 7] & color;
+ backbuffer[y + (x2>>3)] |= x;
+}
+
+void init_T()
+{
+ int y;
+
+ for(y = 0; y < 128*32; y++)
+ {
+ ((uint16_t*)backbuffer)[y] = 0;
+ }
+
+ for(y = 0; y < 256; y++)
+ {
+ uint8_t x1, x2, x4;
+
+ // draw the twister on top of that
+ // Minimal offset is 44 (we don't draw more than that on screen)
+ // For a "standard" twister use: SIN OFF
+ x1 = SIN[(y + 64) %256]/2 + 64; // +64 +64
+ x2 = SIN[y ]/2 + 64; // +0 +64
+ x4 = SIN[(y + 128)%256]/2 + 64; // +128 +64
+
+ // Draw top part
+ line(x1,y,x4,0xFF);
+ line(x2,y,x1,0x55);
+ // Draw bottom part
+ line(255-x1,255-y,255-x2,0xFF);
+ line(255-x4,255-y,255-x1,0x55);
+ }
+
+ // TODO we might as well load a texture, it will look nicer anyway
+ // unless we add some animations to the color ram as well (machine time ?)
+#if 0
+ couleur();
+ for(y = 0; y < 200; y++)
+ {
+ for(x = 8; x < 24; x++)
+ screen[y*40 + x] = (x ^ y/8) & 0x4 ? 0x70:0xE4;
+ screen[y*40 + 7] = 0x80;
+ screen[y*40 + 24] = 0x80;
+ }
+
+ // TODO for this one it's definitely worth using a texture
+ forme();
+ for(y = 0; y < 200; y++)
+ {
+ screen[y * 40 + 7] = 0xFF;
+ screen[y * 40 + 24] = 0xFF;
+ }
+#endif
+
+ asm(
+ " LDX #color_twi-1 \n"
+ " LDU #forme_twi-1 \n"
+ " LBSR decrunchpic \n"
+ :::"x","u", "y");
+
+}
+
+void draw_T(int frame)
+{
+ uint8_t x,y;
+ int y40;
+ uint16_t* scr16 = (uint16_t*)screen;
+ uint16_t* bck16 = (uint16_t*)backbuffer;
+ forme();
+
+ y40 = 0;
+ for(y = 0; y < 200; y++)
+ {
+ const uint8_t line = (y/4 + SIN[frame & 0xFF] + SIN[(frame / 4 + y / 4) & 0xFF]);
+ for(x=4 ;x < 12; x++)
+ {
+ scr16[y40 + x] = bck16[(uint16_t)line * 16 + x];
+ //screen[y40 + x] = backbuffer[(uint16_t)line * 32 + x];
+ }
+
+ y40 += 20;
+ }
+}
diff --git a/code/C/F14/waves.c b/code/C/F14/waves.c
new file mode 100644
index 0000000..79a4f75
--- /dev/null
+++ b/code/C/F14/waves.c
@@ -0,0 +1,91 @@
+// Here's the trick:
+// - unpack the logo to screen memory
+// - The color RAM doesn't move. Part with the logo is shown as expected,
+// below it is an area of single color (we can use the forme part without
+// visible artifacts)
+// - The pixel RAM has the visible copy of the logo, and an hidden copy of the
+// waving part below it
+// - We run over the logo lines, pick from the invisible part and copy to the
+// visible one
+// - Easy way: only vertical ondulations are done.
+// - To do horizontal ondulations, we'd need 8 versions of the logo, each
+// shifted one byte from the previous. This would fill a lot of RAM !
+
+#include <effect.h>
+
+extern unsigned char SIN[256];
+
+asm("\n"
+" .area .text \n"
+" INCLUDEBIN ../LOGO01.CRU \n"
+"forme_logo \n"
+);
+
+void init_L()
+{
+ // TODO clear screen to white
+ couleur();
+ for(unsigned int* i = (unsigned int*)(0); i < (unsigned int*)8000; i++)
+ {
+ *i = 0x7777;
+ }
+
+ forme();
+
+ asm("\n"
+" LDY #5000 \n"
+" LDU #forme_logo-1 \n"
+" LBSR exo2 \n"
+ :::"x", "y");
+
+ // Copy the bottom part of the logo to the top of the screen (pixels only)
+ // We will use this as a source for distorting the actual logo below.
+ unsigned int* src;
+ unsigned int* dest;
+ dest = (unsigned int*)1280;
+ for(src = (unsigned int*)5000; src >= (unsigned int*)3720;)
+ *dest-- = *src--;
+
+ couleur();
+
+ for(int y = 2280; y < 3560; y+=40)
+ {
+ for(int x = 0; x < 40; x+=2)
+ *(unsigned int*)(x+y) = 0x0707;
+ for(int x = 20; x < 28; x+=2)
+ *(unsigned int*)(x+y) = 0x1717;
+ }
+
+ for(int y = 3560; y < 5000; y+=40)
+ {
+ for(int x = 0; x < 40; x+=2)
+ *(unsigned int*)(x+y) = 0x8787;
+ for(int x = 20; x < 28; x+=2)
+ *(unsigned int*)(x+y) = 0x9797;
+ }
+
+ forme();
+
+ return;
+}
+
+
+void draw_L(int frame)
+{
+ for(int y = 0; y < 32; y++)
+ {
+ int offset = (y + (SIN[((y+frame)*4) & 0xFF] >> 6)) * 40;
+ for(int x = 0; x < 40; x++) {
+ *(unsigned int*)(x + y * 40 + 3720) =
+ *(unsigned int*)(x + offset);
+ }
+ }
+
+ asm("\n"
+"z TST 0xA7E7 \n"
+" BMI z \n"
+"bb TST 0xA7E7 \n"
+" BPL bb \n"
+ );
+}
+