2019-12-27 21:35:05 +00:00
|
|
|
// Minimal struct with C-Standard behavior - call return value (not supported yet)
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
.const OFFSET_STRUCT_POINT_Y = 1
|
2020-04-30 20:15:59 +00:00
|
|
|
.label SCREEN = $400
|
2019-12-27 21:35:05 +00:00
|
|
|
main: {
|
|
|
|
.label point1 = 2
|
|
|
|
.label point2 = 4
|
2020-02-23 08:44:36 +00:00
|
|
|
// getPoint(2, 3)
|
2019-12-27 21:35:05 +00:00
|
|
|
lda #3
|
|
|
|
ldx #2
|
|
|
|
jsr getPoint
|
2020-02-23 08:44:36 +00:00
|
|
|
// getPoint(2, 3)
|
|
|
|
// point1 = getPoint(2, 3)
|
2019-12-27 21:35:05 +00:00
|
|
|
stx.z point1
|
|
|
|
sta point1+OFFSET_STRUCT_POINT_Y
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[0] = point1.x
|
2019-12-27 21:35:05 +00:00
|
|
|
txa
|
|
|
|
sta SCREEN
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[1] = point1.y
|
2019-12-27 21:35:05 +00:00
|
|
|
lda point1+OFFSET_STRUCT_POINT_Y
|
|
|
|
sta SCREEN+1
|
2020-02-23 08:44:36 +00:00
|
|
|
// getPoint(4, 5)
|
2019-12-27 21:35:05 +00:00
|
|
|
lda #5
|
|
|
|
ldx #4
|
|
|
|
jsr getPoint
|
2020-02-23 08:44:36 +00:00
|
|
|
// getPoint(4, 5)
|
|
|
|
// point2 = getPoint(4, 5)
|
2019-12-27 21:35:05 +00:00
|
|
|
stx.z point2
|
|
|
|
sta point2+OFFSET_STRUCT_POINT_Y
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[2] = point2.x
|
2019-12-27 21:35:05 +00:00
|
|
|
txa
|
|
|
|
sta SCREEN+2
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[3] = point2.y
|
2019-12-27 21:35:05 +00:00
|
|
|
lda point2+OFFSET_STRUCT_POINT_Y
|
|
|
|
sta SCREEN+3
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-12-27 21:35:05 +00:00
|
|
|
rts
|
|
|
|
}
|
|
|
|
getPoint: {
|
|
|
|
rts
|
|
|
|
}
|