// tested int main() { unsigned char x = set_text(); unsigned char col = (COLOR_GRAY<<4)|COLOR_DKBLUE; unsigned char cnt = 0; // TODO: test - do we need delay between register writes? VDP_SAFE_DELAY(); VDP_SET_REGISTER(VDP_REG_COL, col); VDP_SAFE_DELAY(); VDP_SET_REGISTER(VDP_REG_MODE1, x); charsetlc(); putstring("hello world!\n"); vdpwaitvint(); // to make sure the first wait is not late while (1) { if (vdpwaitvint()) { // wait for an int to occur // it was late - change colors - should not see this happen ++col; VDP_SET_REGISTER(VDP_REG_COL, col); } if (vdpwaitvint()) { // wait for an int to occur // it was late - change colors - should not see this happen ++col; VDP_SET_REGISTER(VDP_REG_COL, col); } VDP_SET_ADDRESS_WRITE(14); // position for counter faster_hexprint(VDP_INT_COUNTER); VDP_SET_ADDRESS_WRITE(54); // position for counter faster_hexprint(++cnt); } return 0; }
void init_spiral(void) { int i; v_hook = no_routine; h_hook = no_routine; current_pal = spiral2_color; current_pal_count = 34; VDP_SET_INC(2); VDP_SET_REGISTER(H_COUNTER, 2); looper = 0; vram_write(0, spiral2_pat, 0x6c00); vram_write(0x7600, font, 3328); vram_write(0xc000, spiral2_scrolla, 0x1000); vram_write(0xe000, spiral2_scrollb, 0x1000); for(i=0;i<0x3ff;i++) { VRAM_WRITE(0xfc00+i, 0); } reset_sprites(); for(i=0;i<80*2;i++) { VRAM_WRITE(SPRITE_BASE+i, 0); } sprite_ram_mutex = 0; shouts_pos = 0; h_hook = h_hook_spiral; v_hook = v_hook_spiral; updating_palette = 0; dma_corrupt = 1; fade_to = 0; }
int set_text64_raw(void) { // note: no masking, full size bitmap mode int unblank = VDP_MODE1_16K | VDP_MODE1_UNBLANK | VDP_MODE1_INT; VDP_SET_REGISTER(VDP_REG_MODE0, VDP_MODE0_BITMAP); VDP_SET_REGISTER(VDP_REG_MODE1, VDP_MODE1_16K); // no need to OR in the sprite mode for now VDP_SET_REGISTER(VDP_REG_SIT, 0x0E); gImage = 0x3800; VDP_SET_REGISTER(VDP_REG_CT, 0xFF); gColor = 0x2000; VDP_SET_REGISTER(VDP_REG_PDT, 0x03); gPattern = 0x0000; VDP_SET_REGISTER(VDP_REG_SAL, 0x76); gSprite = 0x3B00; vdpchar_default(gSprite, 0xd0); VDP_SET_REGISTER(VDP_REG_SDT, 0x03); gSpritePat = 0x1800; nTextRow = 64*23; nTextEnd = 64*24-1; nTextPos = nTextRow; int i; VDP_SET_ADDRESS_WRITE(gImage); for (i = 0; i < 32*24; i++) { VDPWD = i; } vdpmemset(gPattern, 0, 32*24*8); extern unsigned int conio_scrnCol; // conio_bgcolor.c vdpmemset(gColor, conio_scrnCol, 32*24*8); vdpchar = vdpchar64; fast_scrn_scroll = fast_scrn_scroll64; return unblank; }
int set_bitmap(int sprite_mode) { // note: no masking, full size bitmap mode int unblank = VDP_MODE1_16K | VDP_MODE1_UNBLANK | VDP_MODE1_INT | sprite_mode; VDP_SET_REGISTER(VDP_REG_MODE0, VDP_MODE0_BITMAP); VDP_SET_REGISTER(VDP_REG_MODE1, VDP_MODE1_16K); // no need to OR in the sprite mode for now VDP_SET_REGISTER(VDP_REG_SIT, 0x06); gImage = 0x1800; VDP_SET_REGISTER(VDP_REG_CT, 0xFF); gColor = 0x2000; VDP_SET_REGISTER(VDP_REG_PDT, 0x03); gPattern = 0x0000; VDP_SET_REGISTER(VDP_REG_SAL, 0x36); gSprite = 0x1B00; vdpchar(gSprite, 0xd0); VDP_SET_REGISTER(VDP_REG_SDT, 0x03); gSpritePat = 0x1800; nTextRow = 736; nTextEnd = 767; nTextPos = nTextRow; return unblank; }
unsigned char set_multicolor(unsigned char sprite_mode) { // this layout is untested unsigned char unblank = VDP_MODE1_16K | VDP_MODE1_UNBLANK | VDP_MODE1_MULTI | VDP_MODE1_INT | sprite_mode; VDP_SET_REGISTER(VDP_REG_MODE1, VDP_MODE1_16K | VDP_MODE1_MULTI); // no need to OR in the sprite mode for now // because we blanked the display, we don't have to worry about VDP timing for the rest of this VDP_SET_REGISTER(VDP_REG_MODE0, 0); VDP_SET_REGISTER(VDP_REG_SIT, 0x00); gImage = 0x000; VDP_SET_REGISTER(VDP_REG_PDT, 0x01); gPattern = 0x800; VDP_SET_REGISTER(VDP_REG_SAL, 0x36); gSprite = 0x1B00; vdpchar(gSprite, 0xd0); VDP_SET_REGISTER(VDP_REG_SDT, 0x04); gSpritePat = 0x2000; // no color table, it's all in the PDT nTextRow = 736; nTextEnd = 767; nTextPos = nTextRow; return unblank; }
int set_multicolor_raw(int sprite_mode) { // this layout is untested vdpchar = vdpchar_default; int unblank = VDP_MODE1_16K | VDP_MODE1_UNBLANK | VDP_MODE1_MULTI | VDP_MODE1_INT | sprite_mode; VDP_SET_REGISTER(VDP_REG_MODE0, 0); VDP_SET_REGISTER(VDP_REG_MODE1, VDP_MODE1_16K | VDP_MODE1_MULTI); // no need to OR in the sprite mode for now VDP_SET_REGISTER(VDP_REG_SIT, 0x00); gImage = 0x000; VDP_SET_REGISTER(VDP_REG_PDT, 0x01); gPattern = 0x800; VDP_SET_REGISTER(VDP_REG_SAL, 0x36); gSprite = 0x1B00; vdpchar(gSprite, 0xd0); VDP_SET_REGISTER(VDP_REG_SDT, 0x04); gSpritePat = 0x2000; // no color table, it's all in the PDT nTextRow = 736; nTextEnd = 767; nTextPos = nTextRow; return unblank; }
void set_text64_color(void) { int x = set_text64_raw(); VDP_SET_REGISTER(VDP_REG_MODE1, x); VDP_REG1_KSCAN_MIRROR = x; }
int main(void) { v = no_routine; v_hook = no_routine; h_hook = no_routine; pal_mutex = 0; VDP_SET_REGISTER(MODE_SET_1, 0x16); VDP_SET_REGISTER(NAME_TABLE_SCROLLA_BASE, SCROLL_A_ADDR(0xc000)); VDP_SET_REGISTER(NAME_TABLE_WINDOW_BASE, SCROLL_A_ADDR(0x10000)); VDP_SET_REGISTER(NAME_TABLE_SCROLLB_BASE, SCROLL_B_ADDR(0xe000)); VDP_SET_REGISTER(SPRITE_ATTRIBUTE_BASE, SPRITE_ADDR(SPRITE_BASE)); VDP_SET_REGISTER(0x06, 0x00); VDP_SET_REGISTER(BACKGROUND_COLOR, 0x00); VDP_SET_REGISTER(0x08, 0x01); VDP_SET_REGISTER(0x09, 0x01); VDP_SET_REGISTER(H_COUNTER, 1); VDP_SET_REGISTER(MODE_SET_3, HORIZONTAL_LINE); VDP_SET_REGISTER(MODE_SET_4, CELLW_40); VDP_SET_REGISTER(HSCROLL_BASE, HSCROLL_ADDR( 0xfc00)); VDP_SET_REGISTER(0x0e, 0x00); VDP_SET_INC(0x02); VDP_SET_REGISTER(SCROLL_SIZE, SCROLL_WIDTH_64); VDP_SET_REGISTER(WINDOW_X, 0x00); VDP_SET_REGISTER(WINDOW_Y, 0x00); VDP_SET_REGISTER(19, 0x00); VDP_SET_REGISTER(20, 0x00); VDP_SET_REGISTER(21, 0x00); VDP_SET_REGISTER(22, 0x00); z80_write(0,z80_prog, Z80_PROG_LEN); z80_reset(); brightness = -8; fade_to = -8; updating_palette = 0; dma_corrupt = 0; secret_pos = 0; lcontroller = 0; song_pos = 0; song_ticks = 0; VDP_SET_REGISTER(MODE_SET_2, 0x74); proc[0]();// init_sega(); for(;;) { SYNC; update_palette(); if(song_ticks == 0) { h_hook = no_routine; v_hook = no_routine; fade_to = -8; brightness = -8; update_palette(); proc[song_pos*2](); song_ticks = 0; } update_vgm_pos(); proc[(song_pos*2)+1](); song_ticks++; if(vgm_pos>=scenes[song_pos]) { song_pos++; song_ticks = 0; } lcontroller = controller; controller = poll_ctrl1(); if((controller != lcontroller) && (controller != 0)) { if(secret_msg[secret_pos] == controller) secret_pos++; else secret_pos = 0; if(secret_pos == 4) secret(); } } }
void set_bitmap(int sprite_mode) { int x = set_bitmap_raw(sprite_mode); VDP_SET_REGISTER(VDP_REG_MODE1, x); VDP_REG1_KSCAN_MIRROR = x; }
void init_test2(void) { int i; u16 *w; u8 *b; int x,y,sx,sy; current_pal = test3_color; current_pal_count = 48; VDP_SET_REGISTER(H_COUNTER, 1); vram_write(0, test3_pat, 0x4000); vram_write(0xc000, test3_scroll, 0x1000); w = (u16 *)test3_scrollb; for(y=0;y<8;y++) for(x=0;x<8;x++) { for(sy = 0;sy<4;sy++) for(sx = 0;sx<8;sx++) { VRAM_WRITE(0xe000 + (((64*(y+(sy*8)))+(x+(sx*8)))*2), w[(64*y)+x]); } } scanline = 0; for(i=0;i<0x3ff;i++) VRAM_WRITE(0xfc00+i, 0); for(i=0;i<80*8;i++) VRAM_WRITE(SPRITE_BASE+i, 0); vram_write(0x4200,font,3328); // 0x210 sprite_ram_mutex = 0; dist_map = buffer; dist_map2 = buffer2; front = dist_map2; back = dist_map; flip_flop = 0; theta = 0; updating_palette = 1; reset_sprites(); /* for(i = 0;i<strlen(msg1);i++) { put_sprite(20,20+(i*16),1,1,0,0,2,1,0x210 + (( msg1[i] - 'a') * 4)); } for(i = 0;i<strlen(msg2);i++) { put_sprite(270,20+(i*16),1,1,0,0,2,1,0x210 + (( msg2[i] - 'a') * 4)); } for(i = 0;i<strlen(msg3);i++) { put_sprite(290,20+(i*16),1,1,0,0,2,1,0x210 + (( msg3[i] - 'a') * 4)); } do_dma(DMA_68K, DMA_DST_VRAM, (u32 *)sprite_ram, SPRITE_BASE, (sprite_index)*8); */ sprite_ram_mutex = 0; word_count = 0; v_hook = v_bottom_test2; h_hook = h_bottom_test2; looper2 = 0; // add_word(msg1); fade_to = 0; }
void set_multicolor(int sprite_mode) { int x = set_multicolor_raw(sprite_mode); VDP_SET_REGISTER(VDP_REG_MODE1, x); VDP_REG1_KSCAN_MIRROR = x; }