summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-3685.c
blob: d96dcbf92422c572e9143564c6341f27074326d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* bug-3685.c
   Wrong code was generated for an addition involving an operand using exactly one byte of iy.
*/

// Based on code by "Under4Mhz" licensed under GPL 2.0 or later

#include <testfwk.h>

#pragma disable_warning 85

#include <stdint.h>
#include <stdbool.h>

typedef struct {

    uint8_t page;

} VduTileData;

VduTileData vduTileData;

inline uint16_t vdu_tile_page_address( uint8_t page ) {

    return page == 1 ? 0x9000 : 0x9800;
}

inline uint16_t vdu_tile_page_address_get_fast( void ) {

    return vdu_tile_page_address( vduTileData.page );
}

void vdu_tiles_put( uint16_t offset, const uint8_t *pixels, const uint8_t *colours ) {

	static uint16_t o;
	ASSERT (offset == o);
	o += 256;
}

uint16_t decompress_vdu(const uint8_t *compressed_data, uint16_t dest ) {}

///< Render image to screen
void vdu_image_put( const uint8_t **pixels, const uint8_t **colours, const uint8_t *index ) {

    ///< Load data
    uint16_t segmentOffset = 0;
    for( uint8_t segment = 0; segment < 3; segment++ ) {

        vdu_tiles_put( segmentOffset, pixels[segment], colours[segment] );
        segmentOffset += 256; // 256
    }

    // Write index table
    if ( index ) {

        decompress_vdu( index, vdu_tile_page_address_get_fast() );
    }
}

void
testBug(void)
{

    vduTileData.page = 0;

    const uint8_t *const pixels[] = { 0, 0, 0 };
    const uint8_t *const colours[] = { 0, 0, 0 };
    const uint8_t index[] = { 0 };

    vdu_image_put( pixels, colours, index );
}

extern uint16_t vdu_tile_page_address( uint8_t page );

extern uint16_t vdu_tile_page_address_get_fast( void );