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
32 unsigned char lol[5] = { 0xAA, 0x2, 0x3, 0x4, 0x5};
33 unsigned char lol2[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
34 unsigned char lol3[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
35 #define PALETTE_T (volatile unsigned *)0xFE00
36 #define SPRITE_T (volatile unsigned *)0x4000
39 static unsigned char blaat[100];
41 void outport(unsigned char portnr, unsigned char val)
47 :"r"(val), "r"(portnr)
51 unsigned char inport(unsigned char portnr)
65 void setup_audio(void)
67 outport(IO_AUDIO_CTRL, AUDIO_4_NOISE | AUDIO_4_ON);
68 outport(IO_AUDIO_NOISE_CTRL, NOISE_RESET | NOISE_ENABLE | 0x2);
69 outport(IO_AUDIO4_VOL, 0x22);
75 outport(IO_INT_BASE, INT_BASE);
77 unsigned short * test_vec = (INT_BASE + INTVEC_VBLANK_START) << 2;
78 *test_vec++ = (&dummyS_isr);
81 unsigned short * keyboard_intr = (INT_BASE + INTVEC_KEY_PRESS) << 2;
82 *keyboard_intr++ = (&dummyS_isr);
83 *keyboard_intr = (0x2000);
85 outport(IO_INT_ENABLE, INT_VBLANK_START);
86 //outport(IO_INT_ENABLE, INT_KEY_PRESS);
90 static unsigned cnt = 0;
92 void scroll_video(void)
94 unsigned char val = inport(IO_FG_X);
102 outport(IO_FG_X, val);
103 outport(IO_INT_ACK, INT_VBLANK_START);
105 outport(IO_FG_WIN_X0, cnt);
106 outport(IO_FG_WIN_Y0, cnt);
107 outport(IO_FG_WIN_X1, SCREEN_WIDTH - cnt);
108 outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - cnt);
112 void init_video(void)
119 unsigned char ret = inport(0x15);
132 outport(IO_VIDEO_MODE, VMODE_16C_CHK | VMODE_CLEANINIT);
133 unsigned short base = 0x3000; /* screens pos */
134 unsigned short sprite_pos = base - (MAP_SIZE*2) - SPR_TABLE_SIZE;
135 unsigned short scr1_pos = base - (MAP_SIZE*2); /* 0x2000 */
136 unsigned short scr2_pos = base - MAP_SIZE; /* 0x2800 */
137 outport(IO_MAP_BASE, FG_MAP(scr2_pos) | BG_MAP(scr1_pos));
138 outport(IO_SPR_TABLE, SPR_TABLE(sprite_pos));
140 outport(IO_FG_WIN_X0, 10);
141 outport(IO_FG_WIN_Y0, 10);
142 outport(IO_FG_WIN_X1, SCREEN_WIDTH - 10);
143 outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - 10);
148 unsigned char * ptr = PALETTE_T;
149 for (int i = 0; i < sizeof(bgtile_pal); ++i) {
150 *ptr++ = bgtile_pal[i];
154 for (int i = 0; i < sizeof(bgtile_gfx); ++i) {
155 *ptr++ = bgtile_gfx[i];
158 outport(IO_DISPLAY_CTRL, FG_OUT_WIN | FG_ON);