aboutsummaryrefslogtreecommitdiff
path: root/portstat.s
blob: fa68b9f7011d2544be3cec72e82c83cbb728d1de (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

 .export _port_stat_screen, _redraw_port_stat
 .import _port_stat_dirty
 .importzp ptr1, ptr2

 srcptr = ptr1
 dstptr = ptr2

 .include "atari.inc"

; PORTSTAT.DAT is created on the H: device by running mkportstats.xex
; in atari800. H: needs to be set writable and pointed to the current
; directory.

 .rodata
_port_stat_screen:
 .incbin "PORTSTAT.DAT"
screenlen = * - _port_stat_screen
screenpages = >screenlen
partial = <screenlen

 .ifdef CART_TARGET
  .segment "HIGHCODE"
 .else
  .code
 .endif

; only redraw the port status screen if needed. this saves 53 bytes
; compared to using memcpy().
; void redraw_port_stat(void);
_redraw_port_stat:
 lda _port_stat_dirty
 beq @done

 lda #<_port_stat_screen
 sta srcptr
 lda #>_port_stat_screen
 sta srcptr+1

 lda SAVMSC
 sta dstptr
 lda SAVMSC+1
 sta dstptr+1

 ; copy screenpages pages
 ldx #screenpages
 ldy #0
@pageloop:
 lda (srcptr),y
 sta (dstptr),y
 dey
 bne @pageloop
 inc srcptr+1
 inc dstptr+1
 dex
 bne @pageloop

 ; copy last (partial) page. we know Y is 0 here.
 sty _port_stat_dirty
@partloop:
 lda (srcptr),y
 sta (dstptr),y
 iny
 cpy #partial
 bne @partloop

@done:
 rts