2019-07-28 21:05:30 +00:00
|
|
|
// Demonstrates initializing an array of structs
|
|
|
|
// Array of structs containing words
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="initializer-3.prg", type="prg", segments="Program"]
|
|
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
|
|
.segmentdef Basic [start=$0801]
|
|
|
|
.segmentdef Code [start=$80d]
|
|
|
|
.segmentdef Data [startAfter="Code"]
|
|
|
|
.segment Basic
|
2019-07-28 21:05:30 +00:00
|
|
|
:BasicUpstart(main)
|
|
|
|
.const OFFSET_STRUCT_POINT_Y = 1
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-07-28 21:05:30 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __4 = 3
|
2019-07-28 21:05:30 +00:00
|
|
|
.label idx = 2
|
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z idx
|
2019-07-28 21:05:30 +00:00
|
|
|
tax
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[idx++] = points[i].x
|
2019-07-28 21:05:30 +00:00
|
|
|
txa
|
|
|
|
asl
|
2019-08-07 19:00:19 +00:00
|
|
|
stx.z $ff
|
2019-07-28 21:05:30 +00:00
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z $ff
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __4
|
2019-07-28 21:05:30 +00:00
|
|
|
tay
|
|
|
|
lda points,y
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z idx
|
2019-07-28 21:05:30 +00:00
|
|
|
sta SCREEN,y
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[idx++] = points[i].x;
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z idx
|
2021-06-12 18:57:35 +00:00
|
|
|
// BYTE0(points[i].y)
|
2019-09-29 21:13:37 +00:00
|
|
|
ldy.z __4
|
2019-07-28 21:05:30 +00:00
|
|
|
lda points+OFFSET_STRUCT_POINT_Y,y
|
2021-06-12 18:57:35 +00:00
|
|
|
// SCREEN[idx++] = BYTE0(points[i].y)
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z idx
|
2019-07-28 21:05:30 +00:00
|
|
|
sta SCREEN,y
|
2021-06-12 18:57:35 +00:00
|
|
|
// SCREEN[idx++] = BYTE0(points[i].y);
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z idx
|
2021-06-12 18:57:35 +00:00
|
|
|
// BYTE1(points[i].y)
|
2019-09-29 21:13:37 +00:00
|
|
|
ldy.z __4
|
2019-07-28 21:05:30 +00:00
|
|
|
lda points+OFFSET_STRUCT_POINT_Y+1,y
|
2021-06-12 18:57:35 +00:00
|
|
|
// SCREEN[idx++] = BYTE1(points[i].y)
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z idx
|
2019-07-28 21:05:30 +00:00
|
|
|
sta SCREEN,y
|
2021-06-12 18:57:35 +00:00
|
|
|
// SCREEN[idx++] = BYTE1(points[i].y);
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z idx
|
2020-02-23 08:44:36 +00:00
|
|
|
// for( char i: 0..2)
|
2019-07-28 21:05:30 +00:00
|
|
|
inx
|
|
|
|
cpx #3
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-07-28 21:05:30 +00:00
|
|
|
rts
|
|
|
|
}
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Data
|
2019-09-12 23:23:55 +00:00
|
|
|
points: .byte 1
|
2019-07-28 21:05:30 +00:00
|
|
|
.word 2
|
|
|
|
.byte 3
|
|
|
|
.word 4
|
|
|
|
.byte 5
|
|
|
|
.word 6
|