Skip to content

Commit d842048

Browse files
committed
Update zxnext library with the fixed in zx48k
They're the same at this moment
1 parent dc940c6 commit d842048

4 files changed

Lines changed: 46 additions & 28 deletions

File tree

src/arch/zxnext/library-asm/load.asm

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include once <alloc.asm>
21
#include once <free.asm>
32

43
#ifndef HIDE_LOAD_MSG
@@ -26,12 +25,14 @@ LOAD_CODE:
2625
LOCAL LOAD_END
2726
LOCAL VR_CONTROL, VR_CONT_1, VR_CONT_2
2827
LOCAL MEM0
28+
LOCAL TMP_SP
2929

3030
MEM0 EQU 5C92h ; Temporary memory buffer
3131
HEAD1 EQU MEM0 + 8 ; Uses CALC Mem for temporary storage
3232
; Must skip first 8 bytes used by
3333
; PRINT routine
3434
TMP_HEADER EQU HEAD1 + 17 ; Temporary HEADER2 pointer storage
35+
TMP_SP EQU TMP_HEADER + 2 ; Temporary SP storage
3536

3637
#ifdef __ENABLE_BREAK__
3738
LD_BYTES EQU 0556h ; ROM Routine LD-BYTES
@@ -59,6 +60,8 @@ __LOAD_CODE: ; INLINE version
5960
ld (ix + 13), e
6061
ld (ix + 14), d ; Store address in bytes
6162

63+
push hl ; String ptr to be freed later
64+
6265
ld a, h
6366
or l
6467
ld b, h
@@ -99,15 +102,15 @@ LOAD_CONT:
99102
ldir ; Copy String block NAME in header
100103

101104
LOAD_CONT2:
102-
ld bc, 17; 2nd Header
103-
call __MEM_ALLOC
105+
pop hl ; String ptr
106+
call MEM_FREE
104107

105-
ld a, h
106-
or l
107-
jr nz, LOAD_CONT3; there's memory
108-
109-
ld a, ERROR_OutOfMemory
110-
jp __ERROR
108+
ld hl, 0
109+
add hl, sp
110+
ld (TMP_SP), hl
111+
ld bc, -18
112+
add hl, sp
113+
ld sp, hl
111114

112115
LOAD_CONT3:
113116
ld (TMP_HEADER), hl
@@ -239,9 +242,10 @@ LOAD_ERROR:
239242
ld (ERR_NR), a
240243

241244
LOAD_END:
245+
ld hl, (TMP_SP)
246+
ld sp, hl ; Recovers stack
242247
pop ix ; Recovers stack frame pointer
243-
ld hl, (TMP_HEADER) ; Recovers tmp_header pointer
244-
jp MEM_FREE ; Returns via FREE_MEM, freeing tmp header
248+
ret
245249

246250
#ifndef __ENABLE_BREAK__
247251
LOCAL LD_BYTES_RET

src/arch/zxnext/library-asm/print.asm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,8 @@ INVERSE_MODE: ; 00 -> NOP -> INVERSE 0
179179
ld hl, (MAXX)
180180
ld a, e
181181
dec l ; l = MAXX
182-
cp l ; Lower than max?
183-
jp c, __PRINT_CONT; Nothing to do
184-
call __PRINT_EOL1
185-
exx ; counteracts __PRINT_EOL1 exx
186-
jp __PRINT_CONT2
182+
cp l ; Lower than max?
183+
jp nc, __PRINT_EOL1
187184

188185
__PRINT_CONT:
189186
call __SAVE_S_POSN
@@ -218,7 +215,7 @@ __PRINT_EOL2:
218215

219216
__PRINT_AT1_END:
220217
ld hl, (MAXY)
221-
cp h
218+
cp l
222219
jr c, __PRINT_EOL_END ; Carry if (MAXY) < d
223220
#ifndef DISABLE_SCROLL
224221
ld hl, __TVFLAGS
@@ -459,7 +456,11 @@ CONTINUE:
459456
ld b, a
460457
LOOP:
461458
ld a, ' '
459+
push bc
460+
exx
462461
call __PRINTCHAR
462+
exx
463+
pop bc
463464
djnz LOOP
464465
ret
465466
ENDP

src/arch/zxnext/library-asm/random.asm

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ TAKE_FRAMES:
2929
FRAMES EQU 23672
3030
ENDP
3131

32-
RANDOM_SEED_HIGH EQU RAND+6 ; RANDOM seed, 16 higher bits
33-
RANDOM_SEED_LOW EQU 23670 ; RANDOM seed, 16 lower bits
32+
RANDOM_SEED_HIGH EQU RAND+6 ; RANDOM seed, 16 higher bits
33+
RANDOM_SEED_LOW EQU 23670 ; RANDOM seed, 16 lower bits
3434

3535

3636
RAND:
@@ -54,18 +54,17 @@ RAND_LOOP:
5454
rra ; t = t ^ (t >> 1) ^ w
5555
xor d
5656
xor e
57-
ld h,l ; y = z
58-
ld l,a ; w = t
59-
ld (RANDOM_SEED_HIGH),hl
57+
ld d,l ; y = z
58+
ld e,a ; w = t
59+
ld (RANDOM_SEED_HIGH),de
6060
push af
6161
djnz RAND_LOOP
62-
pop af
63-
pop af
64-
ld d, a
62+
pop de
6563
pop af
6664
ld e, a
65+
pop hl
6766
pop af
68-
ld h, a
67+
ld l, a
6968
ret
7069
ENDP
7170

@@ -89,7 +88,7 @@ RND:
8988
; We already have a random 32 bit mantissa in ED CB
9089
; From 0001h to FFFFh
9190

92-
ld l, 81h ; Exponent
91+
ld l, 81h ; Exponent
9392
; At this point we have [0 .. 1) FP number;
9493

9594
; Now we must shift mantissa left until highest bit goes into carry

src/arch/zxnext/library-asm/save.asm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
; YYY and ZZZ are 16 bit on top of the stack.
55

66
#include once <error.asm>
7+
#include once <free.asm>
78

89
SAVE_CODE:
910

@@ -14,16 +15,20 @@ SAVE_CODE:
1415
LOCAL ROM_SAVE
1516
LOCAL __ERR_EMPTY
1617
LOCAL SAVE_STOP
18+
LOCAL STR_PTR
19+
LOCAL SAVE_EMPTY_ERROR
1720

1821
#ifdef __ENABLE_BREAK__
1922
ROM_SAVE EQU 0970h
2023
#endif
2124
MEMBOT EQU 23698 ; Use the CALC mem to store header
25+
STR_PTR EQU MEMBOT + 17
2226

2327
pop hl ; Return address
2428
pop bc ; data length in bytes
2529
pop de ; address start
2630
ex (sp), hl ; CALLE => now hl = String
31+
ld (STR_PTR), hl
2732

2833
; This function will call the ROM SAVE CODE Routine
2934
; Parameters in the stack are HL => String with SAVE name
@@ -34,7 +39,7 @@ SAVE_CODE:
3439
__SAVE_CODE: ; INLINE version
3540
ld a, b
3641
or c
37-
ret z ; Return if block length == 0
42+
jr z, SAVE_EMPTY_ERROR ; Return if block length == 0
3843
3944
push ix
4045
ld a, h
@@ -79,6 +84,8 @@ __ERR_EMPTY:
7984
SAVE_CONT:
8085
ld de, MEMBOT + 1
8186
ldir ; Copy String block NAME
87+
ld hl, (STR_PTR)
88+
call MEM_FREE
8289
ld l, (ix + 13)
8390
ld h, (ix + 14) ; Restores start of bytes
8491

@@ -97,8 +104,15 @@ NO_INT:
97104
pop ix
98105
ret
99106

107+
SAVE_EMPTY_ERROR:
108+
ld a, ERROR_InvalidArg
109+
100110
SAVE_STOP:
101111
pop ix
112+
push af
113+
ld hl, (STR_PTR)
114+
call MEM_FREE
115+
pop af
102116
jp __STOP
103117

104118
#ifndef __ENABLE_BREAK__

0 commit comments

Comments
 (0)