1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-26 03:32:23 +00:00

Improved tetris code by inlining two kickasm-arrays.

This commit is contained in:
jespergravgaard 2020-02-24 22:39:09 +01:00
parent 19b145c207
commit 5fd74a8d39
6 changed files with 5499 additions and 5533 deletions

View File

@ -9,10 +9,6 @@ const char* PLAYFIELD_SCREEN_2 = 0x2c00;
const char* PLAYFIELD_SPRITE_PTRS_1 = (PLAYFIELD_SCREEN_1+SPRITE_PTRS);
// Screen Sprite pointers on screen 2
const char* PLAYFIELD_SPRITE_PTRS_2 = (PLAYFIELD_SCREEN_2+SPRITE_PTRS);
// Address of the original playscreen chars
const char* PLAYFIELD_SCREEN_ORIGINAL = 0x3000;
// Address of the original playscreen colors
const char* PLAYFIELD_COLORS_ORIGINAL = 0x1c00;
// Address of the sprites covering the playfield
const char* PLAYFIELD_SPRITES = 0x2000;
// Address of the charset

View File

@ -10,8 +10,9 @@ kickasm(pc PLAYFIELD_CHARSET, resource "playfield-screen.imap") {{
.import binary "playfield-screen.imap"
}}
// Address of the original playscreen chars
const char PLAYFIELD_SCREEN_ORIGINAL_WIDTH=32;
kickasm(pc PLAYFIELD_SCREEN_ORIGINAL, resource "playfield-screen.iscr", resource "playfield-extended.col" ) {{
const char[] PLAYFIELD_SCREEN_ORIGINAL = kickasm(resource "playfield-screen.iscr", resource "playfield-extended.col" ) {{
// Load chars for the screen
.var screen = LoadBinary("playfield-screen.iscr")
// Load extended colors for the screen
@ -20,12 +21,12 @@ kickasm(pc PLAYFIELD_SCREEN_ORIGINAL, resource "playfield-screen.iscr", resource
// extended.get(i)-1 because the extended colors are 1-based (1/2/3/4)
// <<6 to move extended colors to the upper 2 bits
.fill screen.getSize(), ( (screen.get(i)+1) | (extended.get(i)-1)<<6 )
}}
}};
// Original Color Data
kickasm(pc PLAYFIELD_COLORS_ORIGINAL, resource "playfield-screen.col") {{
const char[] PLAYFIELD_COLORS_ORIGINAL = kickasm(resource "playfield-screen.col") {{
.import binary "playfield-screen.col"
}}
}};
// The color #1 to use for the pieces for each level
char[] PIECES_COLORS_1 = {
@ -194,7 +195,6 @@ void render_moving() {
// Render the next tetromino in the "next" area
void render_next() {
// Find the screen area
unsigned int next_area_offset = 40*12 + 24 + 4;
char* screen_next_area;

View File

@ -90,10 +90,6 @@
.label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS
// Screen Sprite pointers on screen 2
.label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS
// Address of the original playscreen chars
.label PLAYFIELD_SCREEN_ORIGINAL = $3000
// Address of the original playscreen colors
.label PLAYFIELD_COLORS_ORIGINAL = $1c00
// Address of the sprites covering the playfield
.label PLAYFIELD_SPRITES = $2000
// Address of the charset
@ -181,7 +177,6 @@ __b1:
lda #>0>>$10
sta.z score_bcd+3
// kickasm
// Original Color Data
// irq_raster_next = IRQ_RASTER_FIRST
// The raster line of the next IRQ
lda #IRQ_RASTER_FIRST
@ -2081,6 +2076,20 @@ sprites_irq: {
// The initial X/Y for each piece
PIECES_START_X: .byte 4, 4, 4, 4, 4, 4, 4
PIECES_START_Y: .byte 1, 1, 1, 1, 1, 0, 1
PLAYFIELD_SCREEN_ORIGINAL:
// Load chars for the screen
.var screen = LoadBinary("playfield-screen.iscr")
// Load extended colors for the screen
.var extended = LoadBinary("playfield-extended.col")
// screen.get(i)+1 because the charset is loaded into PLAYFIELD_CHARSET+8
// extended.get(i)-1 because the extended colors are 1-based (1/2/3/4)
// <<6 to move extended colors to the upper 2 bits
.fill screen.getSize(), ( (screen.get(i)+1) | (extended.get(i)-1)<<6 )
// Original Color Data
PLAYFIELD_COLORS_ORIGINAL:
.import binary "playfield-screen.col"
// The color #1 to use for the pieces for each level
PIECES_COLORS_1: .byte BLUE, GREEN, PURPLE, BLUE, RED, LIGHT_GREEN, RED, BLUE, LIGHT_BLUE, RED, BLUE, GREEN, PURPLE, BLUE, RED, LIGHT_GREEN, RED, BLUE, LIGHT_BLUE, RED, BLUE, GREEN, PURPLE, BLUE, RED, LIGHT_GREEN, RED, BLUE, LIGHT_BLUE, RED
// The color #2 to use for the pieces for each level
@ -2108,19 +2117,6 @@ sprites_irq: {
.fill 8,$00 // Place a filled char at the start of the charset
.import binary "playfield-screen.imap"
.pc = PLAYFIELD_SCREEN_ORIGINAL "PLAYFIELD_SCREEN_ORIGINAL"
// Load chars for the screen
.var screen = LoadBinary("playfield-screen.iscr")
// Load extended colors for the screen
.var extended = LoadBinary("playfield-extended.col")
// screen.get(i)+1 because the charset is loaded into PLAYFIELD_CHARSET+8
// extended.get(i)-1 because the extended colors are 1-based (1/2/3/4)
// <<6 to move extended colors to the upper 2 bits
.fill screen.getSize(), ( (screen.get(i)+1) | (extended.get(i)-1)<<6 )
.pc = PLAYFIELD_COLORS_ORIGINAL "PLAYFIELD_COLORS_ORIGINAL"
.import binary "playfield-screen.col"
.pc = PLAYFIELD_SPRITES "PLAYFIELD_SPRITES"
.var sprites = LoadPicture("playfield-sprites.png", List().add($010101, $000000))
// Put the sprites into memory

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -64,12 +64,21 @@
(const byte*) PIECE_Z[(number) $40] = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 0, (byte) 0, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 0, (byte) 0, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }
(const byte) PINK = (byte) $a
(const byte*) PLAYFIELD_CHARSET = (byte*) 10240
(const byte*) PLAYFIELD_COLORS_ORIGINAL = (byte*) 7168
(const byte*) PLAYFIELD_COLORS_ORIGINAL[] = kickasm {{ .import binary "playfield-screen.col"
}}
(const byte) PLAYFIELD_COLS = (byte) $a
(const byte) PLAYFIELD_LINES = (byte) $16
(const byte*) PLAYFIELD_SCREEN_1 = (byte*) 1024
(const byte*) PLAYFIELD_SCREEN_2 = (byte*) 11264
(const byte*) PLAYFIELD_SCREEN_ORIGINAL = (byte*) 12288
(const byte*) PLAYFIELD_SCREEN_ORIGINAL[] = kickasm {{ // Load chars for the screen
.var screen = LoadBinary("playfield-screen.iscr")
// Load extended colors for the screen
.var extended = LoadBinary("playfield-extended.col")
// screen.get(i)+1 because the charset is loaded into PLAYFIELD_CHARSET+8
// extended.get(i)-1 because the extended colors are 1-based (1/2/3/4)
// <<6 to move extended colors to the upper 2 bits
.fill screen.getSize(), ( (screen.get(i)+1) | (extended.get(i)-1)<<6 )
}}
(const byte*) PLAYFIELD_SPRITES = (byte*) 8192
(const byte*) PLAYFIELD_SPRITE_PTRS_1 = (const byte*) PLAYFIELD_SCREEN_1+(const word) SPRITE_PTRS
(const byte*) PLAYFIELD_SPRITE_PTRS_2 = (const byte*) PLAYFIELD_SCREEN_2+(const word) SPRITE_PTRS
@ -855,7 +864,7 @@
(const byte) render_show::toD0182_return#0 toD0182_return = >(word)(const byte*) PLAYFIELD_SCREEN_2&(word) $3fff*(byte) 4|>(word)(const byte*) PLAYFIELD_CHARSET/(byte) 4&(byte) $f
(byte*) render_show::toD0182_screen
(const dword*) score_add_bcd[(number) 5] = { fill( 5, 0) }
(dword) score_bcd loadstore zp[4]:23 0.04316546762589928
(dword) score_bcd loadstore zp[4]:23 0.043795620437956206
(const byte**) screen_lines_1[(const byte) PLAYFIELD_LINES] = { fill( PLAYFIELD_LINES, 0) }
(const byte**) screen_lines_2[(const byte) PLAYFIELD_LINES] = { fill( PLAYFIELD_LINES, 0) }
(void()) sid_rnd_init()