3 * Author : Robin Krens <robin@robinkrens.nl>
5 * Last Modified Date: 09.06.2022
6 * Last Modified By : Robin Krens <robin@robinkrens.nl>
11 #include <interrupt.h>
13 extern void * dummyS_isr;
16 unsigned char bgtile_gfx[] = {
17 0x31, 0x22, 0x31, 0x32, 0x22, 0x31, 0x23, 0x21, 0x13, 0x13, 0x31, 0x32,
18 0x32, 0x31, 0x23, 0x12, 0x21, 0x32, 0x13, 0x23, 0x23, 0x13, 0x31, 0x31,
19 0x12, 0x32, 0x13, 0x22, 0x23, 0x13, 0x22, 0x13
23 unsigned char bgtile_pal[] = {
24 0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f,
25 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
26 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
31 unsigned char lol[5] = { 0xAA, 0x2, 0x3, 0x4, 0x5};
32 unsigned char lol2[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
33 unsigned char lol3[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
34 #define PALETTE_T (volatile unsigned *)0xFE00
35 #define SPRITE_T (volatile unsigned *)0x4000
38 static unsigned char blaat[100];
40 void outport(unsigned char portnr, unsigned char val)
46 :"r"(val), "r"(portnr)
50 unsigned char inport(unsigned char portnr)
64 static void __attribute__((used)) dummy()
69 //__attribute__((naked)) void dummy_isr(void)
71 // __asm__("push %ax\n\t"
73 // "popw %bp\n\t" /* HACK: directly pop bp again */
76 // //unsigned char val = inport(IO_BG_X);
79 // //outport(IO_BG_X, val);
80 // //outport(IO_INT_ACK, INT_VBLANK_START);
81 // __asm__("pop %ax\n\t"
90 outport(IO_INT_BASE, INT_BASE);
92 unsigned short * test_vec = (INT_BASE + INTVEC_VBLANK_START) << 2;
93 *test_vec++ = (&dummyS_isr);
96 unsigned short * keyboard_intr = (INT_BASE + INTVEC_KEY_PRESS) << 2;
97 *keyboard_intr++ = (&dummyS_isr);
98 *keyboard_intr = (0x2000);
100 outport(IO_INT_ENABLE, INT_VBLANK_START);
101 //outport(IO_INT_ENABLE, INT_KEY_PRESS);
105 static unsigned cnt = 0;
107 void scroll_video(void)
109 unsigned char val = inport(IO_FG_X);
117 outport(IO_FG_X, val);
118 outport(IO_INT_ACK, INT_VBLANK_START);
120 outport(IO_FG_WIN_X0, cnt);
121 outport(IO_FG_WIN_Y0, cnt);
122 outport(IO_FG_WIN_X1, SCREEN_WIDTH - cnt);
123 outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - cnt);
127 void init_video(void)
134 unsigned char ret = inport(0x15);
146 outport(IO_VIDEO_MODE, VMODE_16C_CHK | VMODE_CLEANINIT);
147 unsigned short base = 0x3000; /* screens pos */
148 unsigned short sprite_pos = base - (MAP_SIZE*2) - SPR_TABLE_SIZE;
149 unsigned short scr1_pos = base - (MAP_SIZE*2); /* 0x2000 */
150 unsigned short scr2_pos = base - MAP_SIZE; /* 0x2800 */
151 outport(IO_MAP_BASE, FG_MAP(scr2_pos) | BG_MAP(scr1_pos));
152 outport(IO_SPR_TABLE, SPR_TABLE(sprite_pos));
154 outport(IO_FG_WIN_X0, 10);
155 outport(IO_FG_WIN_Y0, 10);
156 outport(IO_FG_WIN_X1, SCREEN_WIDTH - 10);
157 outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - 10);
162 unsigned char * ptr = PALETTE_T;
163 for (int i = 0; i < sizeof(bgtile_pal); ++i) {
164 *ptr++ = bgtile_pal[i];
168 for (int i = 0; i < sizeof(bgtile_gfx); ++i) {
169 *ptr++ = bgtile_gfx[i];
172 outport(IO_DISPLAY_CTRL, FG_OUT_WIN | FG_ON);