Skip to content

Commit 22916fc

Browse files
fix compression names (fix #152)
1 parent 71e1921 commit 22916fc

File tree

19 files changed

+175
-289
lines changed

19 files changed

+175
-289
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
path = tools/convpng
66
url = https://github.com/MattWaltz/convpng
77
[submodule "src/sub/libload"]
8-
path = src/sub/libload
8+
path = src/libload
99
url = https://github.com/CE-Programming/libload.git
1010
[submodule "tools/convtile"]
1111
path = tools/convtile

examples/gfx_fullscreen_tiled_image/src/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
#include <stdlib.h>
99
#include <string.h>
1010

11-
#include <decompress.h>
11+
#include <compression.h>
1212
#include <graphx.h>
13-
#include <debug.h>
1413

1514
/* Include the graphics */
1615
#include "gfx/tiles_gfx.h"
@@ -43,7 +42,7 @@ void main(void) {
4342

4443
/* Decompress the tiles */
4544
for (; i < tileset_tiles_num; i++) {
46-
dzx7_Turbo(tileset_tiles_compressed[i], tile);
45+
zx7_Decompress(tile, tileset_tiles_compressed[i]);
4746
gfx_Sprite_NoClip(tile, x, y);
4847
x += TILE_WIDTH;
4948
if (x >= LCD_WIDTH) {

examples/gfx_sprite_compress/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <stdlib.h>
99
#include <string.h>
1010

11-
#include <decompress.h>
11+
#include <compression.h>
1212
#include <graphx.h>
1313

1414
/* Include the graphics file */
@@ -20,10 +20,10 @@ void main(void) {
2020
gfx_sprite_t *apple;
2121

2222
/* Allocate space for the decompressed sprite */
23-
apple = gfx_MallocSprite(apple_width, apple_height); // Same as: gfx_AllocSprite(apple_width, apple_height, malloc)
23+
apple = gfx_MallocSprite(apple_width, apple_height); /* Same as: gfx_AllocSprite(apple_width, apple_height, malloc) */
2424

2525
/* Decompress the sprite */
26-
dzx7_Standard(apple_compressed, apple); // or dzx7_Turbo
26+
zx7_Decompress(apple, apple_compressed);
2727

2828
/* Initialize the 8bpp graphics */
2929
gfx_Begin();

examples/gfx_sprite_rotate_scale/src/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <string.h>
1010

1111
#include <graphx.h>
12-
#include <debug.h>
1312

1413
#include "gfx/logo_gfx.h"
1514

examples/gfx_tilemap_compress/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <stdlib.h>
88
#include <string.h>
99

10-
#include <decompress.h>
10+
#include <compression.h>
1111
#include <graphx.h>
1212

1313
/* Include the graphics */
@@ -43,14 +43,14 @@ void main(void) {
4343
gfx_sprite_t *tmp_ptr;
4444
gfx_tilemap_t tilemap;
4545

46-
/* Decompress the tiles */
46+
/* Decompress the compressed tiles */
4747
for (i = 0; i < sizeof(tileset_tiles)/sizeof(gfx_sprite_t*) ; i++) {
48-
tmp_ptr = gfx_MallocSprite(TILE_WIDTH, TILE_HEIGHT); // Same as gfx_AllocSprite(TILE_WIDTH, TILE_HEIGHT, malloc)
49-
dzx7_Turbo(tileset_tiles_compressed[i], tmp_ptr); // or dzx7_Standard, but in this case we have a lot of tiles
48+
tmp_ptr = gfx_MallocSprite(TILE_WIDTH, TILE_HEIGHT); /* Same as gfx_AllocSprite(TILE_WIDTH, TILE_HEIGHT, malloc) */
49+
zx7_Decompress(tmp_ptr, tileset_tiles_compressed[i]);
5050
tileset_tiles[i] = tmp_ptr;
5151
}
5252

53-
dzx7_Turbo(tilemap_compressed, tilemap_map);
53+
zx7_Decompress(tilemap_map, tilemap_compressed);
5454

5555
/* Initialize the tilemap structure */
5656
tilemap.map = tilemap_map;

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ install: $(DIRS) chmod
197197
$(MAKE) -C $(FILEIOCDIR) install PREFIX=$(PREFIX) DESTDIR=$(DESTDIR)
198198
$(MAKE) -C $(CEDIR) install PREFIX=$(PREFIX) DESTDIR=$(DESTDIR)
199199
$(MAKE) -C $(STDDIR) install PREFIX=$(PREFIX) DESTDIR=$(DESTDIR)
200-
$(CPDIR) $(call NATIVEPATH,$(SRCDIR)/sub/compat) $(call NATIVEPATH,$(INSTALLINC))
200+
$(CPDIR) $(call NATIVEPATH,$(SRCDIR)/compatibility) $(call NATIVEPATH,$(INSTALLINC))
201201

202202
$(DIRS):
203203
$(call MKDIR,$(INSTALLBIN))

src/ce/compression.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file
3+
* @author Matt "MateoConLechuga" Waltz
4+
* @brief Optimized (de)compression routines
5+
*/
6+
7+
#ifndef COMPRESSION_H
8+
#define COMPRESSION_H
9+
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
14+
/**
15+
* Decompress a block of zx7 encoded data
16+
*
17+
* @param dest Pointer to destination for uncompressed data
18+
* @param src Pointer to compressed data
19+
*/
20+
void zx7_Decompress(void *dest, void *src);
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
25+
26+
#endif
27+

src/ce/intce.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* @brief Interrupt configuring and setting
66
*/
77

8-
#ifndef H_INTCE
9-
#define H_INTCE
8+
#ifndef INTCE_H
9+
#define INTCE_H
1010

1111
#include <stdint.h>
1212

@@ -38,19 +38,22 @@ asm("halt")
3838
/**
3939
* Initizalize to use custom interrupts
4040
* @note Saves status of current interrupt state
41+
* @warning TI has removed custom interrupt support on CE models with hardware revision >= I.
4142
*/
4243
void int_Initialize(void);
4344

4445
/**
4546
* Resets interrupts back to the OS expected values
4647
* @warning Must have called int_Initialize before using
48+
* @warning TI has removed custom interrupt support on CE models with hardware revision >= I.
4749
*/
4850
void int_Reset(void);
4951

5052
/**
5153
* Sets up an interrupt vector given an ISR
5254
* @param ivect Interrupt vector to set
5355
* @param handler Handler to interrupt service routine
56+
* @warning TI has removed custom interrupt support on CE models with hardware revision >= I.
5457
*/
5558
void int_SetVector(uint8_t ivect, void (*handler)(void));
5659

src/ce/zx7_Decompress.src

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
; ---
2+
; void zx7_Decompress(void *dest, void *src)
3+
; ---
4+
; Dec 2012 by Einar Saukas & Urusergi
5+
; "Turbo" version (89 bytes, 25% faster)
6+
; ---
7+
8+
.def _zx7_Decompress
9+
.assume adl=1
10+
11+
; enter : hl = void *src
12+
; de = void *dst
13+
;
14+
; exit : hl = & following uncompressed block
15+
;
16+
; uses : af, bc, de, hl
17+
18+
_zx7_Decompress:
19+
pop bc
20+
pop de
21+
pop hl
22+
push hl
23+
push de
24+
push bc
25+
26+
ld a, 128
27+
28+
zx7t_copy_byte_loop:
29+
30+
ldi ; copy literal byte
31+
32+
zx7t_main_loop:
33+
34+
add a, a ; check next bit
35+
call z, zx7t_load_bits ; no more bits left?
36+
jr nc, zx7t_copy_byte_loop ; next bit indicates either literal or sequence
37+
38+
; determine number of bits used for length (Elias gamma coding)
39+
40+
push de
41+
ld de, 0
42+
ld bc, 1
43+
44+
zx7t_len_size_loop:
45+
46+
inc d
47+
add a, a ; check next bit
48+
call z, zx7t_load_bits ; no more bits left?
49+
jr nc, zx7t_len_size_loop
50+
jp zx7t_len_value_start
51+
52+
; determine length
53+
54+
zx7t_len_value_loop:
55+
56+
add a, a ; check next bit
57+
call z, zx7t_load_bits ; no more bits left?
58+
rl c
59+
rl b
60+
jr c, zx7t_exit ; check end marker
61+
62+
zx7t_len_value_start:
63+
64+
dec d
65+
jr nz, zx7t_len_value_loop
66+
inc bc ; adjust length
67+
68+
; determine offset
69+
70+
ld e, (hl) ; load offset flag (1 bit) + offset value (7 bits)
71+
inc hl
72+
73+
sla e
74+
inc e
75+
76+
jr nc, zx7t_offset_end ; if offset flag is set, load 4 extra bits
77+
add a, a ; check next bit
78+
call z, zx7t_load_bits ; no more bits left?
79+
rl d ; insert first bit into D
80+
add a, a ; check next bit
81+
call z, zx7t_load_bits ; no more bits left?
82+
rl d ; insert second bit into D
83+
add a, a ; check next bit
84+
call z, zx7t_load_bits ; no more bits left?
85+
rl d ; insert third bit into D
86+
add a, a ; check next bit
87+
call z, zx7t_load_bits ; no more bits left?
88+
ccf
89+
jr c, zx7t_offset_end
90+
inc d ; equivalent to adding 128 to DE
91+
92+
zx7t_offset_end:
93+
94+
rr e ; insert inverted fourth bit into E
95+
96+
; copy previous sequence
97+
98+
ex (sp), hl ; store source, restore destination
99+
push hl ; store destination
100+
sbc hl, de ; HL = destination - offset - 1
101+
pop de ; DE = destination
102+
ldir
103+
104+
zx7t_exit:
105+
106+
pop hl ; restore source address (compressed data)
107+
jp nc, zx7t_main_loop
108+
109+
zx7t_load_bits:
110+
111+
ld a, (hl) ; load another group of 8 bits
112+
inc hl
113+
rla
114+
ret
115+
116+
117+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
These files in this folder are maintained for compatibility with older toolchain versions and should no longer be referenced.

0 commit comments

Comments
 (0)