3 * Author : Robin Krens <robin@robinkrens.nl>
5 * Last Modified Date: 09.06.2022
6 * Last Modified By : Robin Krens <robin@robinkrens.nl>
12 #include <interrupt.h>
14 extern void * dummyS_isr;
17 unsigned char bgtile_gfx[] = {
18 0x31, 0x22, 0x31, 0x32, 0x22, 0x31, 0x23, 0x21, 0x13, 0x13, 0x31, 0x32,
19 0x32, 0x31, 0x23, 0x12, 0x21, 0x32, 0x13, 0x23, 0x23, 0x13, 0x31, 0x31,
20 0x12, 0x32, 0x13, 0x22, 0x23, 0x13, 0x22, 0x13
24 //unsigned char bgtile_pal[] = {
25 // 0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f,
26 // 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
27 // 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
30 unsigned char bgtile_pal[] = {
31 0x00, 0x00, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0x00, 0x00, 0x12, 0x0b,
32 0x00, 0x00, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
33 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
38 unsigned char lol[5] = { 0xAA, 0x2, 0x3, 0x4, 0x5};
39 unsigned char lol2[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
40 unsigned char lol3[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
41 #define PALETTE_T (volatile unsigned *)0xFE00
42 #define SPRITE_T (volatile unsigned *)0x4000
45 static unsigned char blaat[100];
47 void outport(unsigned char portnr, unsigned char val)
53 :"r"(val), "r"(portnr)
57 unsigned char inport(unsigned char portnr)
71 void setup_audio(void)
73 outport(IO_AUDIO_CTRL, AUDIO_4_NOISE | AUDIO_4_ON);
74 outport(IO_AUDIO_NOISE_CTRL, NOISE_RESET | NOISE_ENABLE | 0x2);
75 outport(IO_AUDIO4_VOL, 0x22);
81 outport(IO_INT_BASE, INT_BASE);
83 unsigned short * test_vec = (INT_BASE + INTVEC_VBLANK_START) << 2;
84 *test_vec++ = (&dummyS_isr);
87 unsigned short * keyboard_intr = (INT_BASE + INTVEC_KEY_PRESS) << 2;
88 *keyboard_intr++ = (&dummyS_isr);
89 *keyboard_intr = (0x2000);
91 //outport(IO_INT_ENABLE, INT_VBLANK_START);
92 //outport(IO_INT_ENABLE, INT_KEY_PRESS);
96 static unsigned cnt = 0;
98 void scroll_video(void)
100 unsigned char val = inport(IO_FG_X);
108 outport(IO_FG_X, val);
109 outport(IO_INT_ACK, INT_VBLANK_START);
111 outport(IO_FG_WIN_X0, cnt);
112 outport(IO_FG_WIN_Y0, cnt);
113 outport(IO_FG_WIN_X1, SCREEN_WIDTH - cnt);
114 outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - cnt);
118 void init_video(void)
125 unsigned char ret = inport(0x15);
138 outport(IO_VIDEO_MODE, VMODE_16C_CHK | VMODE_CLEANINIT);
139 unsigned short base = 0x3000; /* screens pos */
140 unsigned short sprite_pos = base - (MAP_SIZE*2) - SPR_TABLE_SIZE;
141 unsigned short scr1_pos = base - (MAP_SIZE*2); /* 0x2000 */
142 unsigned short scr2_pos = base - MAP_SIZE; /* 0x2800 */
143 outport(IO_MAP_BASE, FG_MAP(scr2_pos) | BG_MAP(scr1_pos));
144 outport(IO_SPR_TABLE, SPR_TABLE(sprite_pos));
146 outport(IO_FG_WIN_X0, 10);
147 outport(IO_FG_WIN_Y0, 10);
148 outport(IO_FG_WIN_X1, SCREEN_WIDTH - 10);
149 outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - 10);
154 unsigned char * ptr = PALETTE_T;
155 for (int i = 0; i < sizeof(bgtile_pal); ++i) {
156 *ptr++ = bgtile_pal[i];
160 for (int i = 0; i < sizeof(bgtile_gfx); ++i) {
161 *ptr++ = bgtile_gfx[i];
164 outport(IO_DISPLAY_CTRL, FG_OUT_WIN | FG_ON);