mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-10-25 00:02:16 +00:00
gb: gb.color, GB_CGB_FLAGS, color mode sets default palette
and: const params = PLATFORM_PARAMS[platform] || PLATFORM_PARAMS[getBasePlatform(platform)];
This commit is contained in:
1 parent
4f719500eb
commit
0d42ddf732
12 files changed
+75
-21
No files matched your search
@@ -153,6 +153,7 @@ body {
|
||||
<li><a class="dropdown-item" href="?platform=atari8-5200">Atari 5200</a></li>
|
||||
<li><a class="dropdown-item" href="?platform=atari7800">Atari 7800</a></li>
|
||||
<li><a class="dropdown-item" href="?platform=gb">Game Boy</a></li>
|
||||
<li><a class="dropdown-item" href="?platform=gb.color">Game Boy Color</a></li>
|
||||
<li><a class="dropdown-item" href="?platform=pce">PC Engine</a></li>
|
||||
<!--
|
||||
<li><a class="dropdown-item" href="?platform=vectrex">Vectrex</a></li>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "gb/types.h"
|
||||
#include "gb/hardware.h"
|
||||
#include "gb/gb.h"
|
||||
#include "gb/cgb.h"
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
@@ -209,6 +210,15 @@ const Level levels[LEVELS_FIXED] = {
|
||||
{ 16, 13, level_5 },
|
||||
};
|
||||
|
||||
/*{pal:555,n:16}*/
|
||||
palette_color_t bkg_palettes[1][4] = {
|
||||
{ 0x2062, 0x318E, 0x6A28, 0x7714 },
|
||||
};
|
||||
/*{pal:555,n:16}*/
|
||||
palette_color_t fg_palettes[1][4] = {
|
||||
{ 0x73DB, 0x4BDC, 0x2B31, 0x14A3 },
|
||||
};
|
||||
|
||||
/* Filled by generate_level() for endless mazes after the fixed set */
|
||||
char gen_row[MAP_H_MAX][MAP_W_MAX + 1];
|
||||
byte gen_w, gen_h;
|
||||
@@ -784,6 +794,11 @@ void draw_cell(byte x, byte y) {
|
||||
}
|
||||
}
|
||||
|
||||
void set_color_palettes(byte i) {
|
||||
set_bkg_palette(0, 1, bkg_palettes[i]);
|
||||
set_sprite_palette(0, 1, fg_palettes[i]);
|
||||
}
|
||||
|
||||
void draw_hud(void) {
|
||||
byte lv = (byte)(game_level + 1);
|
||||
put_str_win(0, 0, "L");
|
||||
@@ -1394,6 +1409,7 @@ void setup_graphics(void) {
|
||||
set_bkg_1bpp_data(0, 32, font_1bpp);
|
||||
set_bkg_data(BKG_BASE, 13, bkg_tiles);
|
||||
set_sprite_data(16, 12, sprite_tiles);
|
||||
set_color_palettes(0);
|
||||
/* same font tiles for window HUD */
|
||||
for (x = 0; x < 20; x++) set_win_tile_xy(x, 0, 0);
|
||||
SPRITES_8x16;
|
||||
|
||||
@@ -149,6 +149,9 @@ _refresh_OAM::
|
||||
.org 0x134
|
||||
.asciz "Title"
|
||||
|
||||
.org 0x143
|
||||
.byte GB_CGB_FLAGS
|
||||
|
||||
.org 0x144
|
||||
.byte 0,0,0
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "gb/types.h"
|
||||
#include "gb/hardware.h"
|
||||
#include "gb/gb.h"
|
||||
#include "gb/cgb.h"
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
@@ -81,6 +82,15 @@ byte sfx_timer;
|
||||
byte sfx_kind; /* 0=off 1/2=waka 3=eat 4=death 6=power */
|
||||
byte death_phase;
|
||||
|
||||
/*{pal:555,n:4}*/
|
||||
palette_color_t bkg_palette[4] = {
|
||||
0x2062, 0x5A31, 0x2A16, 0x6B11,
|
||||
};
|
||||
/*{pal:555,n:4}*/
|
||||
palette_color_t fg_palette[4] = {
|
||||
0x1462, 0x463C, 0x2B31, 0x7FFF,
|
||||
};
|
||||
|
||||
const uint8_t font_1bpp[] = {
|
||||
/* 0 space */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* 1 '0' */ 0x3C,0x66,0x6E,0x76,0x66,0x66,0x3C,0x00,
|
||||
@@ -612,6 +622,8 @@ void setup_graphics(void) {
|
||||
set_bkg_1bpp_data(0, 35, font_1bpp);
|
||||
set_bkg_data(BKG_BASE, 4, bkg_tiles);
|
||||
set_sprite_data(SPR_BASE, SPR_TILE_COUNT, sprite_tiles);
|
||||
set_bkg_palette(0, 1, bkg_palette);
|
||||
set_sprite_palette(0, 1, fg_palette);
|
||||
SPRITES_8x16;
|
||||
BGP_REG = 0xE4;
|
||||
OBP0_REG = 0xE4;
|
||||
|
||||
@@ -32,6 +32,7 @@ Controls: D-pad moves player 1, Start starts the game.
|
||||
#include "gb/types.h"
|
||||
#include "gb/hardware.h"
|
||||
#include "gb/gb.h"
|
||||
#include "gb/cgb.h"
|
||||
#include "gbtext.h"
|
||||
|
||||
typedef uint8_t byte;
|
||||
@@ -41,6 +42,11 @@ typedef uint16_t word;
|
||||
#define COLS 20
|
||||
#define ROWS 17
|
||||
|
||||
/*{pal:555,n:4}*/
|
||||
palette_color_t bkg_palette[4] = {
|
||||
0x6FFF, 0x5A31, 0x2A1F, 0x00,
|
||||
};
|
||||
|
||||
////////// GAME DATA
|
||||
|
||||
typedef struct {
|
||||
@@ -331,6 +337,8 @@ void play_game() {
|
||||
void main() {
|
||||
byte i, x, y;
|
||||
DISPLAY_OFF;
|
||||
// set CGB background palette 0
|
||||
set_bkg_palette(0, 1, bkg_palette);
|
||||
// unsigned tile indexing so ASCII codes work; must be set before
|
||||
// set_bkg_data(), which uses it to pick the VRAM tile base
|
||||
LCDC_REG |= LCDCF_BG8000;
|
||||
|
||||
+13
-2
@@ -17,6 +17,14 @@ function cgbColorToARGB(lo: number, hi: number): number {
|
||||
return 0xFF000000 | (b8 << 16) | (g8 << 8) | r8;
|
||||
}
|
||||
|
||||
// CGB boot ROM default palette: 8 palettes of white/light-grey/dark-grey/black.
|
||||
// Each entry is a little-endian 15-bit BGR555 color (0x7FFF, 0x56B5, 0x294A, 0x0000).
|
||||
// Without this, CGB mode starts with palette RAM all-zeroed/white and DMG-style
|
||||
// games that rely on the default shades render blank.
|
||||
var CGB_DEFAULT_PALETTE = new Uint8Array([
|
||||
0xFF, 0x7F, 0xB5, 0x56, 0x4A, 0x29, 0x00, 0x00,
|
||||
]);
|
||||
|
||||
var GB_KEYCODE_MAP = makeKeycodeMap([
|
||||
// D-pad
|
||||
[Keys.RIGHT, 0, 0x01],
|
||||
@@ -673,6 +681,7 @@ export class GameBoyMachine extends BasicScanlineMachine {
|
||||
sampleRate = 154 * 60 * 4; // ~36960 Hz: 4 audio samples per scanline
|
||||
overscan = false;
|
||||
defaultROMSize = 0x8000; // 32KB minimum
|
||||
aspectRatio = 10/9;
|
||||
|
||||
cpu: SM83 = new SM83();
|
||||
ram = new Uint8Array(0x2000); // Work RAM (C000-DFFF)
|
||||
@@ -1576,8 +1585,10 @@ export class GameBoyMachine extends BasicScanlineMachine {
|
||||
this.vramBankSelect = 0;
|
||||
this.wramBanks.fill(0);
|
||||
this.wramBankSelect = 1;
|
||||
this.bgCRAM.fill(0xFF);
|
||||
this.objCRAM.fill(0xFF);
|
||||
for (var pal = 0; pal < 8; pal++) {
|
||||
this.bgCRAM.set(CGB_DEFAULT_PALETTE, pal * 8);
|
||||
this.objCRAM.set(CGB_DEFAULT_PALETTE, pal * 8);
|
||||
}
|
||||
this.bgCRAMIndex = 0;
|
||||
this.bgCRAMAutoInc = false;
|
||||
this.objCRAMIndex = 0;
|
||||
|
||||
+3
-6
@@ -80,18 +80,15 @@ class GameBoyPlatform extends BaseMachinePlatform<GameBoyMachine> implements Pla
|
||||
}
|
||||
}
|
||||
|
||||
const GBC_PRESETS: Preset[] = [
|
||||
//{ id: 'hello_color.c', name: 'Hello Color World (C)' },
|
||||
];
|
||||
|
||||
class GameBoyColorPlatform extends GameBoyPlatform {
|
||||
|
||||
newMachine() {
|
||||
var m = new GameBoyMachine();
|
||||
m.forceColor = true;
|
||||
// not needed, gb.color sets the CGB header byte to 0x80
|
||||
//m.forceColor = true;
|
||||
return m;
|
||||
}
|
||||
getPresets() { return GBC_PRESETS; }
|
||||
getPresets() { return GB_PRESETS; }
|
||||
|
||||
getROMExtension() {
|
||||
return ".gbc";
|
||||
|
||||
@@ -265,7 +265,7 @@ export function getToolForFilename(fn: string, platform: string): string {
|
||||
if (override) return override;
|
||||
// a specialization like verilog-vga has no params of its own; its root
|
||||
// platform's arch is the one that applies
|
||||
var params = PLATFORM_PARAMS[base] || PLATFORM_PARAMS[getRootBasePlatform(platform)];
|
||||
var params = PLATFORM_PARAMS[platform] || PLATFORM_PARAMS[base] || PLATFORM_PARAMS[getRootBasePlatform(platform)];
|
||||
var arch = params && params.arch;
|
||||
switch (arch) {
|
||||
case 'z80':
|
||||
|
||||
@@ -135,17 +135,16 @@ export class Builder {
|
||||
* one source file's directives can't follow the next build around.
|
||||
*/
|
||||
paramsForBuild(platform: string) {
|
||||
const base = getBasePlatform(platform);
|
||||
if (!this.buildParams[base]) {
|
||||
const params = PLATFORM_PARAMS[base];
|
||||
if (!this.buildParams[platform]) {
|
||||
const params = PLATFORM_PARAMS[platform] || PLATFORM_PARAMS[getBasePlatform(platform)];
|
||||
const copy = {};
|
||||
// values are strings, numbers, and arrays of those
|
||||
for (const key in params) {
|
||||
copy[key] = Array.isArray(params[key]) ? params[key].slice() : params[key];
|
||||
}
|
||||
this.buildParams[base] = copy;
|
||||
this.buildParams[platform] = copy;
|
||||
}
|
||||
return this.buildParams[base];
|
||||
return this.buildParams[platform];
|
||||
}
|
||||
|
||||
async executeBuildSteps(): Promise<WorkerResult> {
|
||||
|
||||
+13
-5
@@ -395,6 +395,7 @@ export var PLATFORM_PARAMS = {
|
||||
'-g', '_shadow_OAM=0xC000',
|
||||
'-g', '.STACK=0xE000',
|
||||
'-g', '.refresh_OAM=0xFF80',
|
||||
'-g', 'GB_CGB_FLAGS=0x0',
|
||||
],
|
||||
wiz_sys_type: 'gb',
|
||||
wiz_inc_dir: 'gb',
|
||||
@@ -410,8 +411,15 @@ export var PLATFORM_PARAMS = {
|
||||
},
|
||||
};
|
||||
|
||||
// SMS/GG mode-4 variants of the shared libcv common.[ch] (2 bytes per tile, 32x28)
|
||||
PLATFORM_PARAMS['sms-sms-libcv'] = { ...PLATFORM_PARAMS['sms-sg1000-libcv'],
|
||||
extra_preproc_args: ['-I', '.', '-D', 'CV_SMS', '-D', 'CV_MODE4'] };
|
||||
PLATFORM_PARAMS['sms-gg-libcv'] = PLATFORM_PARAMS['sms-sms-libcv'];
|
||||
|
||||
// SMS/GG mode-4 variants of the shared libcv common.[ch] (2 bytes per tile, 32x28)
|
||||
PLATFORM_PARAMS['sms-sms-libcv'] = {
|
||||
...PLATFORM_PARAMS['sms-sg1000-libcv'],
|
||||
extra_preproc_args: ['-I', '.', '-D', 'CV_SMS', '-D', 'CV_MODE4']
|
||||
};
|
||||
|
||||
PLATFORM_PARAMS['sms-gg-libcv'] = PLATFORM_PARAMS['sms-sms-libcv'];
|
||||
|
||||
PLATFORM_PARAMS['gb.color'] = {
|
||||
...PLATFORM_PARAMS['gb'],
|
||||
extra_link_args: PLATFORM_PARAMS['gb'].extra_link_args.map(arg => arg === 'GB_CGB_FLAGS=0x0' ? 'GB_CGB_FLAGS=0x80' : arg)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ function makeCPPSafe(s: string): string {
|
||||
export function preprocessMCPP(step: BuildStep, filesys: string) {
|
||||
load("mcpp");
|
||||
var platform = step.platform;
|
||||
var params = PLATFORM_PARAMS[getBasePlatform(platform)];
|
||||
var params = PLATFORM_PARAMS[platform] || PLATFORM_PARAMS[getBasePlatform(platform)];
|
||||
if (!params) throw Error("Platform not supported: " + platform);
|
||||
// <stdin>:2: error: Can't open include file "foo.h"
|
||||
var errors = [];
|
||||
|
||||
@@ -19,7 +19,6 @@ import * as oscar64 from './tools/oscar64'
|
||||
import * as xa from './tools/xa'
|
||||
import * as dialog from './tools/dialog'
|
||||
|
||||
import { PLATFORM_PARAMS } from "./platforms";
|
||||
|
||||
export const TOOLS = {
|
||||
'dasm': dasm.assembleDASM,
|
||||
|
||||
Reference in new issue
Block a user