Skip to content

Commit

Permalink
Add min/max functionality to random utility, start implementing retur…
Browse files Browse the repository at this point in the history
…n forwarding
  • Loading branch information
beckadamtheinventor committed Sep 8, 2024
1 parent a5ef8ca commit 85e0a25
Show file tree
Hide file tree
Showing 20 changed files with 1,517 additions and 30 deletions.
Binary file added artifacts/1.19.1314 alpha/BOSOS.8xp
Binary file not shown.
Binary file added artifacts/1.19.1314 alpha/BOSOS.rom
Binary file not shown.
Binary file added artifacts/1.19.1314 alpha/BOSOSPT2.BIN
Binary file not shown.
Binary file added artifacts/1.19.1314 alpha/BOSOSpt2.8xv
Binary file not shown.
Binary file added artifacts/1.19.1314 alpha/BOSUPDTR.BIN
Binary file not shown.
1,231 changes: 1,231 additions & 0 deletions artifacts/1.19.1314 alpha/bos_internal.inc

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ namespace bos
?sys_ExecContinue := $226E4
?fs_IsOSBackupPresent := $226E8
?util_SHA256 := $226EC
?str_FromByte := $226F0
?str_FromInt := $226F4
?str_FromLong := $226F8
?str_ToInt := $226FC
; end of jump table
;-------------------------------------------------------------------------------
; OS memory areas and misc defines
Expand Down
8 changes: 8 additions & 0 deletions bos.src
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
public _sys_ExecContinue
public _fs_IsOSBackupPresent
public _util_SHA256
public _str_FromByte
public _str_FromInt
public _str_FromLong
public _str_ToInt
_boot_os := $20108
_handle_interrupt := $2010C
_HandleInstruction := $20110
Expand Down Expand Up @@ -376,6 +380,10 @@ _sys_ExecBegin := $226E0
_sys_ExecContinue := $226E4
_fs_IsOSBackupPresent := $226E8
_util_SHA256 := $226EC
_str_FromByte := $226F0
_str_FromInt := $226F4
_str_FromLong := $226F8
_str_ToInt := $226FC

public ram_executable
public ram_executable_at
Expand Down
4 changes: 4 additions & 0 deletions src/data/adrive/src/fs/bin/include/bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ namespace bos
?sys_ExecContinue := $226E4
?fs_IsOSBackupPresent := $226E8
?util_SHA256 := $226EC
?str_FromByte := $226F0
?str_FromInt := $226F4
?str_FromLong := $226F8
?str_ToInt := $226FC
; end of jump table
;-------------------------------------------------------------------------------
; OS memory areas and misc defines
Expand Down
61 changes: 60 additions & 1 deletion src/data/adrive/src/fs/bin/random.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,65 @@
jr random_main
db "FEX",0
random_main:
ld hl,-8
call ti._frameset
call bos.sys_Random32
ld (ix-4),hl
ld (ix-1),e
ld a,(ix+6)
dec a
jr z,.no_args
dec a
jr z,.one_arg
dec a
jr nz,.info
.two_args:
call osrt.argv_1
push hl
call bos.str_ToInt
pop bc
ld (ix-8),hl
call osrt.argv_2
push hl
call bos.str_ToInt
pop bc
ld bc,(ix-8)
xor a,a
sbc hl,bc
push hl
pop bc
ld hl,(ix-4)
ld e,(ix-1)
call ti._lremu
ld bc,(ix-8)
add hl,bc
ld e,a
jr .no_args
.one_arg:
call osrt.argv_1
push hl
call bos.str_ToInt
ex (sp),hl
pop bc
ld hl,(ix-4)
ld e,(ix-1)
call ti._lremu
jr .no_args
.no_args:
ld a,mReturnLong or mReturnNotError
ld (bos.return_code_flags),a
jp bos.sys_Random32
.done:
ld sp,ix
pop ix
ret

.info:
ld hl,.info_str
call bos.gui_PrintLine
jr .done

.info_str:
db "random",$A
db "random (max)",$A
db "random (min) (max)"
db 0
4 changes: 4 additions & 0 deletions src/data/adrive/src/fs/lib/include/bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ namespace bos
?sys_ExecContinue := $226E4
?fs_IsOSBackupPresent := $226E8
?util_SHA256 := $226EC
?str_FromByte := $226F0
?str_FromInt := $226F4
?str_FromLong := $226F8
?str_ToInt := $226FC
; end of jump table
;-------------------------------------------------------------------------------
; OS memory areas and misc defines
Expand Down
2 changes: 1 addition & 1 deletion src/data/buildno.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.1214 alpha
1.19.1314 alpha
4 changes: 4 additions & 0 deletions src/include/bos.inc
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ namespace bos
?sys_ExecContinue := $226E4
?fs_IsOSBackupPresent := $226E8
?util_SHA256 := $226EC
?str_FromByte := $226F0
?str_FromInt := $226F4
?str_FromLong := $226F8
?str_ToInt := $226FC
; end of jump table
;-------------------------------------------------------------------------------
; OS memory areas and misc defines
Expand Down
5 changes: 4 additions & 1 deletion src/str.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ include 'str/set.asm'
include 'str/toupper.asm'
include 'str/upper.asm'
include 'str/HexToInt.asm'

include 'str/ToInt.asm'
include 'str/FromByte.asm'
include 'str/FromInt.asm'
include 'str/FromLong.asm'
14 changes: 14 additions & 0 deletions src/str/FromByte.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
;@DOES Convert num to a base-10 string.
;@INPUT char *str_FromByte(char *dest, uint8_t num);
str_FromByte:
pop bc,de,hl
push hl,de,bc
push de,de
ex (sp),iy
ld a,l
or a,a
sbc hl,hl
ld l,a
xor a,a
ld e,a
jr str_FromLong.long_to_str_100
10 changes: 10 additions & 0 deletions src/str/FromInt.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;@DOES Convert num to a base-10 string.
;@INPUT char *str_FromInt(char *dest, unsigned int num);
str_FromInt:
pop bc,de,hl
push hl,de,bc
push de,de
ex (sp),iy
xor a,a
ld e,a
jr str_FromLong.long_to_str_10m
64 changes: 64 additions & 0 deletions src/str/FromLong.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
;@DOES Convert num to a base-10 string.
;@INPUT char *str_FromLong(char *dest, uint32_t num);
str_FromLong:
push iy
ld iy,0
add iy,sp
ld hl,(iy+9)
ld a,(iy+12)
ld iy,(iy+6)
pop bc
push iy,bc
ld e,1000000000 shr 24
ld bc,1000000000 and $FFFFFF
call .num_to_str_aqu
ld e,100000000 shr 24
ld bc,100000000 and $FFFFFF
call .num_to_str_aqu
ld e,0
.long_to_str_10m:
ld bc,10000000
call .num_to_str_aqu
ld bc,1000000
call .num_to_str_aqu
ld bc,100000
call .num_to_str_aqu
.long_to_str_10k:
ld bc,10000
call .num_to_str_aqu
ld bc,1000
call .num_to_str_aqu
.long_to_str_100:
ld bc,100
call .num_to_str_aqu
ld c,10
call .num_to_str_aqu
ld c,1
call .num_to_str_aqu
ld (iy),0
pop iy,hl
.skip_zeroes_loop:
ld a,(hl)
or a,a
jr z,.return_single_zero
cp a,'0'
ret nz
inc hl
jr .skip_zeroes_loop
.return_single_zero:
dec hl
ret

.num_to_str_aqu:
ld d,'0'-1
.num_to_str_aqu.loop:
inc d
or a,a
sbc hl,bc
sbc a,e
jr nc,.num_to_str_aqu.loop
add hl,bc
adc a,e
ld (iy),d
inc iy
ret
File renamed without changes.
Loading

0 comments on commit 85e0a25

Please sign in to comment.