Added default palette

This commit is contained in:
Kyle Cardoza 2024-03-29 02:49:14 -04:00
parent ed7c89a3f4
commit 8f36498bf5
4 changed files with 88 additions and 6 deletions

View File

@ -1,6 +1,6 @@
(define memories '(
(memory HighRAM
(address (#x010000 . #x017FFF))
(address (#x010000 . #x01EFFF))
(section farcode)
(section fardata)
(section far)
@ -16,7 +16,7 @@
)
(memory HighBSS
(address (#x018000 . #x01FFFF))
(address (#x01F000 . #x01FFFF))
(section heap)
(section huge)
(section zhuge)
@ -62,7 +62,7 @@
(block stack (size #x200)) ; machine stack size
(block heap (size #x2000))
(block heap (size #x0001))
(base-address _DirectPageStart DirectPage 0)

View File

@ -55,7 +55,9 @@ typedef struct vera_palette_s {
};
} VeraPalette;
extern void vera_init(void);
void vera_init(void);
extern void vera_reset(void);
extern void vera_set_data0_address(uint32_t addr);
@ -93,6 +95,8 @@ void vera_write(uint32_t dest, void *src, size_t length);
void vera_memset(uint32_t addr, uint8_t value, size_t length);
VeraPaletteEntry vera_make_palette_entry(uint32_t rgb_value);
VeraPaletteEntry vera_get_palette_entry(uint8_t index);
void vera_set_palette_entry(uint8_t index, VeraPaletteEntry value);

View File

@ -8,7 +8,7 @@
.section code
.public vera_init
.public vera_reset
.public vera_set_data0_address
.public vera_set_data1_address
.public vera_peek_data0
@ -23,7 +23,20 @@
.extern _Dp
vera_init:
vera_reset:
phb
short_a
; Set the data bank to 0
lda #0
pha
plb
lda #0b10000000
tsb 0xDF05
long_a
plb
rts
; Set the data0 address.

View File

@ -11,6 +11,15 @@
#include "config.h"
#include "drivers/vera.h"
static inline void vera_init_palette(void);
void
vera_init()
{
vera_reset();
vera_init_palette();
}
uint8_t
vera_read_byte(uint32_t addr)
{
@ -109,3 +118,59 @@ vera_palette_write(VeraPalette *src)
{
vera_write(0x0001FA00, src, sizeof(VeraPalette));
}
VeraPaletteEntry
vera_make_palette_entry(uint32_t rgb_value)
{
return (VeraPaletteEntry){
.red = (uint8_t)((rgb_value & 0x00F00000) >> 20),
.green = (uint8_t)((rgb_value & 0x0000F000) >> 12),
.blue = (uint8_t)((rgb_value & 0x000000F0) >> 4)
};
}
static uint32_t const vera_default_palette[256] = {
0x000000, 0x111111, 0x222222, 0x333333, 0x444444, 0x555555, 0x666666, 0x777777,
0x888888, 0x999999, 0xaaaaaa, 0xbbbbbb, 0xcccccc, 0xdddddd, 0xeeeeee, 0xffffff,
0x007f7f, 0x3fbfbf, 0x00ffff, 0xbfffff, 0x8181ff, 0x0000ff, 0x3f3fbf, 0x00007f,
0x0f0f50, 0x7f007f, 0xbf3fbf, 0xf500f5, 0xfd81ff, 0xffc0cb, 0xff8181, 0xff0000,
0xbf3f3f, 0x7f0000, 0x551414, 0x7f3f00, 0xbf7f3f, 0xff7f00, 0xffbf81, 0xffffbf,
0xffff00, 0xbfbf3f, 0x7f7f00, 0x007f00, 0x3fbf3f, 0x00ff00, 0xafffaf, 0x00bfff,
0x007fff, 0x4b7dc8, 0xbcafc0, 0xcbaa89, 0xa6a090, 0x7e9494, 0x6e8287, 0x7e6e60,
0xa0695f, 0xc07872, 0xd08a74, 0xe19b7d, 0xebaa8c, 0xf5b99b, 0xf6c8af, 0xf5e1d2,
0x7f00ff, 0x573b3b, 0x73413c, 0x8e5555, 0xab7373, 0xc78f8f, 0xe3abab, 0xf8d2da,
0xe3c7ab, 0xc49e73, 0x8f7357, 0x73573b, 0x3b2d1f, 0x414123, 0x73733b, 0x8f8f57,
0xa2a255, 0xb5b572, 0xc7c78f, 0xdadaab, 0xededc7, 0xc7e3ab, 0xabc78f, 0x8ebe55,
0x738f57, 0x587d3e, 0x465032, 0x191e0f, 0x235037, 0x3b573b, 0x506450, 0x3b7349,
0x578f57, 0x73ab73, 0x64c082, 0x8fc78f, 0xa2d8a2, 0xe1f8fa, 0xb4eeca, 0xabe3c5,
0x87b48e, 0x507d5f, 0x0f6946, 0x1e2d23, 0x234146, 0x3b7373, 0x64abab, 0x8fc7c7,
0xabe3e3, 0xc7f1f1, 0xbed2f0, 0xabc7e3, 0xa8b9dc, 0x8fabc7, 0x578fc7, 0x57738f,
0x3b5773, 0x0f192d, 0x1f1f3b, 0x3b3b57, 0x494973, 0x57578f, 0x736eaa, 0x7676ca,
0x8f8fc7, 0xababe3, 0xd0daf8, 0xe3e3ff, 0xab8fc7, 0x8f57c7, 0x73578f, 0x573b73,
0x3c233c, 0x463246, 0x724072, 0x8f578f, 0xab57ab, 0xab73ab, 0xebace1, 0xffdcf5,
0xe3c7e3, 0xe1b9d2, 0xd7a0be, 0xc78fb9, 0xc87da0, 0xc35a91, 0x4b2837, 0x321623,
0x280a1e, 0x401811, 0x621800, 0xa5140a, 0xda2010, 0xd5524a, 0xff3c0a, 0xf55a32,
0xff6262, 0xf6bd31, 0xffa53c, 0xd79b0f, 0xda6e0a, 0xb45a00, 0xa04b05, 0x5f3214,
0x53500a, 0x626200, 0x8c805a, 0xac9400, 0xb1b10a, 0xe6d55a, 0xffd510, 0xffea4a,
0xc8ff41, 0x9bf046, 0x96dc19, 0x73c805, 0x6aa805, 0x3c6e14, 0x283405, 0x204608,
0x0c5c0c, 0x149605, 0x0ad70a, 0x14e60a, 0x7dff73, 0x4bf05a, 0x00c514, 0x05b450,
0x1c8c4e, 0x123832, 0x129880, 0x06c491, 0x00de6a, 0x2deba8, 0x3cfea5, 0x6affcd,
0x91ebff, 0x55e6ff, 0x7dd7f0, 0x08ded5, 0x109cde, 0x055a5c, 0x162c52, 0x0f377d,
0x004a9c, 0x326496, 0x0052f6, 0x186abd, 0x2378dc, 0x699dc3, 0x4aa4ff, 0x90b0ff,
0x5ac5ff, 0xbeb9fa, 0x786ef0, 0x4a5aff, 0x6241f6, 0x3c3cf5, 0x101cda, 0x0010bd,
0x231094, 0x0c2148, 0x5010b0, 0x6010d0, 0x8732d2, 0x9c41ff, 0xbd62ff, 0xb991ff,
0xd7a5ff, 0xd7c3fa, 0xf8c6fc, 0xe673ff, 0xff52ff, 0xda20e0, 0xbd29ff, 0xbd10c5,
0x8c14be, 0x5a187b, 0x641464, 0x410062, 0x320a46, 0x551937, 0xa01982, 0xc80078,
0xff50bf, 0xff6ac5, 0xfaa0b9, 0xfc3a8c, 0xe61e78, 0xbd1039, 0x98344d, 0x911437
};
void
vera_init_palette(void)
{
VeraPaletteEntry colour;
for (int i = 0; i < 255; i += 1) {
colour = vera_make_palette_entry(vera_default_palette[i]);
vera_set_palette_entry(i, colour);
}
}