Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

straighten out endianness and sprite rasterization

  • Loading branch information...
commit a6498ece8b997ea59eb09e5f0b780548dfa2129d 1 parent 18d21c0
@mental authored
View
2  spec/image-specs/scroll-mode1.case
@@ -4,4 +4,4 @@ should support text-style scrolling in mode 1
7f00: 00 ff
0008: 80 c0 e0 f0 f8 fc fe ff ff fe fc f8 f0 e0 c0 80
0800: 0101
-0840: 0102
+0840: 0201
View
6 spec/image-specs/scroll-mode2.case
@@ -5,6 +5,6 @@ should support smooth scrolling in mode 2
0010: 4000 5000 5400 5500 5540 5550 5554 5555
0020: 5555 5554 5550 5540 5500 5400 5000 4000
0030: 4444 1111 4444 1111 4444 1111 4444 1111
-0c00: 0002
-0ac0: 0001
-0b00: 0003
+0c00: 0200
+0ac0: 0100
+0b00: 0300
View
6 spec/image-specs/scroll-mode3.case
@@ -5,6 +5,6 @@ should support smooth scrolling in mode 3
0020: 10000000 11000000 11100000 11110000 11111000 11111100 11111110 11111111
0040: 11111111 11111110 11111100 11111000 11110000 11100000 11000000 10000000
0060: 10101010 01010101 10101010 01010101 10101010 01010101 10101010 01010101
-0c00: 0002
-0ac0: 0001
-0b00: 0003
+0c00: 0200
+0ac0: 0100
+0b00: 0300
View
2  spec/image-specs/sprites-doubling.case
@@ -1,5 +1,5 @@
should render doubled sprites
7ff8: 0b
7f10: 00 3f
-7e00: 00 01 0001 10 01 0801 00 11 0401 10 11 0c01
+7e00: 00 01 0100 10 01 0108 00 11 0104 10 11 010c
2020: 01010101 10101010 01010101 10101010 01010101 10101010 01010101 10101010
View
6 spec/image-specs/sprites-mode2.case
@@ -1,8 +1,8 @@
should show first 8 sprites per line in mode 2
7ff8: 0a
7f10: 00 02 08 0a 20 22 38 2a 15 17 1d 1f 35 37 3d 3f
-7e00: 00 01 0001 08 01 0002 10 01 0101 18 01 0102
-7e10: 20 01 0201 28 01 0202 30 01 0301 38 01 0302
-7e20: 40 01 0001 48 01 0002 50 01 0001 58 01 0002
+7e00: 00 01 0100 08 01 0200 10 01 0101 18 01 0201
+7e10: 20 01 0102 28 01 0202 30 01 0103 38 01 0203
+7e20: 40 01 0100 48 01 0200 50 01 0100 58 01 0200
2020: 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
2040: 02020202 20202020 02020202 20202020 02020202 20202020 02020202 20202020
View
6 spec/image-specs/sprites-mode3.case
@@ -1,8 +1,8 @@
should show first 8 sprites per line in mode 3
7ff8: 0b
7f10: 00 02 08 0a 20 22 38 2a 15 17 1d 1f 35 37 3d 3f
-7e00: 00 01 0001 08 01 0002 10 01 0101 18 01 0102
-7e10: 20 01 0201 28 01 0202 30 01 0301 38 01 0302
-7e20: 40 01 0001 48 01 0002 50 01 0001 58 01 0002
+7e00: 00 01 0100 08 01 0200 10 01 0101 18 01 0201
+7e10: 20 01 0102 28 01 0202 30 01 0103 38 01 0203
+7e20: 40 01 0100 48 01 0200 50 01 0100 58 01 0200
2020: 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
2040: 02020202 20202020 02020202 20202020 02020202 20202020 02020202 20202020
View
2  spec/image-specs/sprites-ordering.case
@@ -1,5 +1,5 @@
should render lower-numbered sprites over higher-numbered ones
7ff8: 0b
7f10: 00 30 00 00 00 0c 00 00
-7e00: 00 01 0001 04 05 0101
+7e00: 00 01 0100 04 05 0101
2020: 01010101 10101010 01010101 10101010 01010101 10101010 01010101 10101010
View
2  spec/image-specs/text-colors.case
@@ -2,4 +2,4 @@ should allow setting cell fg and bg colors in text mode
7ff8: 05
7f00: 03 0c 30
0000: ff ff ff ff 00 00 00 00
-0800: 1200
+0800: 0012
View
8 spec/image-specs/tile-attributes-mode2.case
@@ -3,7 +3,7 @@ should implement tile attributes in mode 2
7f00: 00 02 08 0a 20 22 38 2a 15 17 1d 1f 35 37 3d 3f
7f10: 3f 3d 37 35 1f 1d 17 15 2a 38 22 20 0a 08 02 00
0010: 5500 5500 5500 5500 ffaa ffaa ffaa ffaa
-0800: 2001 2201 2401 2601 2801 2a01 2c01 2e01
-0840: 3001 3201 3401 3601 3801 3a01 3c01 3e01
-0880: 0001 0201 0401 0601 0801 0a01 0c01 0e01
-08c0: 1001 1201 1401 1601 1801 1a01 1c01 1e01
+0800: 0120 0122 0124 0126 0128 012a 012c 012e
+0840: 0130 0132 0134 0136 0138 013a 013c 013e
+0880: 0100 0102 0104 0106 0108 010a 010c 010e
+08c0: 0110 0112 0114 0116 0118 011a 011c 011e
View
8 spec/image-specs/tile-attributes-mode3.case
@@ -3,7 +3,7 @@ should implement tile attributes in mode 3
7f00: 00 02 08 0a 20 22 38 2a 15 17 1d 1f 35 37 3d 3f
7f10: 3f 3d 37 35 1f 1d 17 15 2a 38 22 20 0a 08 02 00
0020: 33221100 33221100 77665544 77665544 bbaa9988 bbaa9988 ffeeddcc ffeeddcc
-0800: 2001 2201 2401 2601 2801 2a01 2c01 2e01
-0840: 3001 3201 3401 3601 3801 3a01 3c01 3e01
-0880: 0001 0201 0401 0601 0801 0a01 0c01 0e01
-08c0: 1001 1201 1401 1601 1801 1a01 1c01 1e01
+0800: 0120 0122 0124 0126 0128 012a 012c 012e
+0840: 0130 0132 0134 0136 0138 013a 013c 013e
+0880: 0100 0102 0104 0106 0108 010a 010c 010e
+08c0: 0110 0112 0114 0116 0118 011a 011c 011e
View
5 spec/retrograph_spec.rb
@@ -50,11 +50,10 @@ def build_image_spec(case_file, image_file)
File.open(case_file, "r") do |stream|
description = stream.readline.strip
stream.each_line do |line|
- offset, data = line.split(':').map { |t| t.strip }
+ offset, data = line.split(':', 2).map { |t| t.strip }
data, offset = offset, nil unless data
- data = data.split(/\s+/).map { |w| w.scan(/[a-zA-Z0-9]{2}/).reverse }
- data = data.map { |w| [w.join('')].pack("H*") }.join('')
offset = Integer("0x#{offset}")
+ data = [data.gsub(/\s+/, '')].pack("H*")
unless data.empty?
if offset
writes << [offset, data]
View
22 src/retrograph.c
@@ -361,12 +361,16 @@ static void render_line_text_b(retrograph_pixel_t *out_buffer, uint8_t const *na
}
}
-static inline uint16_t unpack_uint16(uint8_t const * const bytes) {
- return (uint16_t)((bytes[1] << 8) | bytes[0]);
+static inline uint16_t unpack_uint16be(uint8_t const * const bytes) {
+ return (uint16_t)((bytes[0] << 8) | bytes[1]);
+}
+
+static inline uint32_t unpack_uint32be(uint8_t const * const bytes) {
+ return (uint32_t)((bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]);
}
-static inline uint32_t unpack_uint32(uint8_t const * const bytes) {
- return (uint32_t)((bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0]);
+static inline uint16_t unpack_uint16le(uint8_t const * const bytes) {
+ return (uint16_t)((bytes[1] << 8) | bytes[0]);
}
#define RENDER_SINGLE_PIXEL out_buffer[i] = palette[color | base_color]
@@ -412,10 +416,10 @@ static inline void render_ ## suffix ## bpp(retrograph_pixel_t *out_buffer, \
} \
}
-DEFINE_RENDER_TILE(2, tile, RENDER_SINGLE_PIXEL, uint16_t, unpack_uint16)
-DEFINE_RENDER_TILE(2, tile_double, RENDER_DOUBLE_PIXEL, uint16_t, unpack_uint16)
-DEFINE_RENDER_TILE(4, tile, RENDER_SINGLE_PIXEL, uint32_t, unpack_uint32)
-DEFINE_RENDER_TILE(4, tile_double, RENDER_DOUBLE_PIXEL, uint32_t, unpack_uint32)
+DEFINE_RENDER_TILE(2, tile, RENDER_SINGLE_PIXEL, uint16_t, unpack_uint16be)
+DEFINE_RENDER_TILE(2, tile_double, RENDER_DOUBLE_PIXEL, uint16_t, unpack_uint16be)
+DEFINE_RENDER_TILE(4, tile, RENDER_SINGLE_PIXEL, uint32_t, unpack_uint32be)
+DEFINE_RENDER_TILE(4, tile_double, RENDER_DOUBLE_PIXEL, uint32_t, unpack_uint32be)
#define DEFINE_RENDER_BG_LINE(bpp) \
static void render_bg_line ## bpp(retrograph_pixel_t *out_buffer, \
@@ -446,7 +450,7 @@ static void render_bg_line ## bpp(retrograph_pixel_t *out_buffer, \
name_cursor = names; \
for (i = 0; i < x_coarse; i++) { \
uint16_t cell; \
- cell = unpack_uint16(name_cursor) ^ toggle_bits; \
+ cell = unpack_uint16le(name_cursor) ^ toggle_bits; \
if (!(cell & PRIORITY_MASK)) { \
render_tile ## bpp(out_buffer, cell, vflip_patterns, palette); \
} \
Please sign in to comment.
Something went wrong with that request. Please try again.