-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path47loader_instascreen.asm
80 lines (74 loc) · 2.96 KB
/
47loader_instascreen.asm
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
75
76
77
78
79
80
;; 47loader (c) Stephen Williams 2013
;; See LICENSE for distribution terms
;; This routine loads a pixmap into the display file, attributes
;; into high memory, then LDIRs the attributes onto the screen
;; while reading edges. The loader can then resume to load the
;; game with no pause; the effect is a Speedlock-style instant
;; loading screen.
;;
;; The routine assumes forwards loading.
;;
;; Define:
;;
;; LOADER_INSTASCREEN_ATTR_ADDRESS:
;; address in uncontended memory to which to load the attrs
;;
;; LOADER_INSTASCREEN_FILL_COLOUR:
;; 0-7, number of colour with which to fill the screen. If
;; not defined, defaults to 0.
;;
;; LOADER_INSTASCREEN_FILL_BRIGHT:
;; if set, the colour specified by LOADER_INSTASCREEN_FILL_COLOUR
;; is made bright.
if LOADER_INSTASCREEN_ATTR_ADDRESS < 32768
.error Load attributes into uncontended memory
endif
ifdef LOADER_INSTASCREEN_FILL_COLOUR
if LOADER_INSTASCREEN_FILL_COLOUR % 8 != 0
;; fill colour is not black; set paper and ink colour
;; to be the same
.instascreen_colour:defl LOADER_INSTASCREEN_FILL_COLOUR % 8
.instascreen_colour:defl .instascreen_colour | (.instascreen_colour << 3)
ifdef LOADER_INSTASCREEN_FILL_BRIGHT
.instascreen_colour:defl .instascreen_colour | 64
endif
endif
endif
loader_instascreen:
;; clear attributes
ld hl,0x5800 ; address of first attr
ifdef .instascreen_colour
ld (hl),.instascreen_colour; attr to fill screen
else
ld (hl),l ; L = 0; fill screen with black
endif
ld de,0x5801
ld bc,767
ldir
;; load pixmap directly into screen
ld ix,0x4000
ld d,0x18 ; DE=0x1800
call loader_entry
ifndef LOADER_DIE_ON_ERROR
ret nc ; bail out on error
endif
;; load attrs into high memory
ld ix,LOADER_INSTASCREEN_ATTR_ADDRESS
;ld de,768
ld d,3 ; DE=0x300, 768
call loader_resume
ifndef LOADER_DIE_ON_ERROR
ret nc
endif
;; copy attributes to screen, reading an edge
;; every 32 bytes
ld d,0x58 ; DE=0x5800 b/c DE=0 after a load
ld hl,LOADER_INSTASCREEN_ATTR_ADDRESS
.copy_loop:
ld bc,32
ldir ; copy this block
call .read_edge ; (this call corrupts A and B)
ld a,0x5a ; when done, DE will be pointing at 0x5B00
cp d ; compare D against 0x5A
jr nc,.copy_loop ; loop if no overflow, i.e. D <= 0x5A
ret ; return with carry set to indicate success