News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_zhulien

Julian's Long List of Ideas Thread

Started by zhulien, 17:54, 12 February 25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zhulien

Quote from: eto on 08:54, 13 February 25How can I use the VDU from the CPC? All the examples just specify the URL but what hardware/software on the CPC is required?
You need an M4 card or a Cyboard.

eto

Quote from: zhulien on 02:05, 14 February 25
Quote from: eto on 08:54, 13 February 25How can I use the VDU from the CPC? All the examples just specify the URL but what hardware/software on the CPC is required?
You need an M4 card or a Cyboard.
So nothing on the CPC side, but an endpoint on a webserver?

zhulien

Quote from: eto on 08:14, 14 February 25
Quote from: zhulien on 02:05, 14 February 25
Quote from: eto on 08:54, 13 February 25How can I use the VDU from the CPC? All the examples just specify the URL but what hardware/software on the CPC is required?
You need an M4 card or a Cyboard.
So nothing on the CPC side, but an endpoint on a webserver?
Yes, you do an http get with the rsx provided by m4

I have been thinking of making a library of rsx commands to make it easier for those who never called webserviced before

zhulien

#28
Today on the way home from work, I was thinking, I have lots of RAM on my CPC, why can't i run lots of BASICs at the same time.

Now, this is far from doing that, but as an initial POC, I was thinking, from memory there is nothing stored in the OS ROMs that do anything with banking, so... we should in theory be able to store lots of the first 64kb into the other banks, and swap between them.  To make it "safer" for now, to avoid e.g. keyboard presses to swap tasks, we could use RSXs, like |1, |2, |3 (first 192kb of 256kb memory expansion).  the 4th bank first block initially to preserve the registers and anything else we may need to preserve.

Anyway, it is ALMOST finished, but was wondering is there any reason it shouldn't work?  If the entire state of the computer is stored (ok, as much as we can store) in each 64kb bank upon system reset, then we could do some BASIC in |1, change to |2 to do something else, maybe an other BASIC program, |3 to do something else etc...  If this POC works, it could be extended to be more useful - maybe instead of preserving just 64kb, maybe preserve 128kb on 1mb computers, and have |1 to |2.  Maybe then an alt+tab extension, or ctrl+1, ctrl+2...

Code so far (a little to do to make a working POC):

; TODO:
; honor lower ROM enabling
; enable and disable upper ROM in the ramlam function
; preserve initial registers correctly (including alternate and SP)
;
;FUTURE:
; can we fit a |4 within the 256kb extra RAM?
; perhaps support 128kb machines with memory swap-in-place
; dynamically detect memory sizes
; don't use macros? but we have plenty of ROM space for now

TXT_OUT_CHAR equ #bb5a
RAM_LAM equ #2000

org #c000

write direct -1,1,#C0

macro block_main
push bc
ld bc,  #7fc0
out (c), c
pop bc
endm

macro block_4
ld bc,  #7fc4
out (c), c
endm

macro block_5
ld bc,  #7fc5
out (c), c
endm

macro block_6
ld bc,  #7fc6
out (c), c
endm

macro block_7
ld bc,  #7fc7
out (c), c
endm

macro block_8
ld bc,  #7fcc
out (c), c
endm

macro block_9
ld bc,  #7fcd
out (c), c
endm

macro block_10
ld bc,  #7fce
out (c), c
endm

macro block_11
ld bc,  #7fcf
out (c), c
endm

macro block_12
ld bc,  #7fd4
out (c), c
endm

macro block_13
ld bc,  #7fd5
out (c), c
endm

macro block_14
ld bc,  #7fd6
out (c), c
endm

macro block_15
ld bc,  #7fd7
out (c), c
endm

macro block_registers
push bc
ld bc,  #7fdc
out (c), c
pop bc
endm

macro save_reg1 ;save registers for bank 1
block_registers

ld (#4000), sp

ld sp, #4100 ;set new sp so we can push the other registers faster
push af
push bc
push de
push hl
push ix
push iy
exx
push bc
push de
push hl
exx

ld sp, (#4000)

block_main
endm

macro save_reg2 ;save registers for bank 2
block_registers

ld (#5000), sp

ld sp, #5100 ;set new sp so we can push the other registers faster
push af
push bc
push de
push hl
push ix
push iy
exx
push bc
push de
push hl
exx

ld sp, (#5000)

block_main
endm

macro save_reg3 ;save registers for bank 3
block_registers

ld (#6000), sp

ld sp, #6100 ;set new sp so we can push the other registers faster
push af
push bc
push de
push hl
push ix
push iy
exx
push bc
push de
push hl
exx

ld sp, (#6000)

block_main
endm

macro load_reg1 ;load registers for bank 1
block_registers

ld (#4000), sp

ld sp, #4100-18 ;set new sp so we can pop the other registers faster
exx
pop hl
pop de
pop bc
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af

ld sp, (#4000)

block_main
endm

macro load_reg2 ;load registers for bank 2
block_registers

ld (#5000), sp

ld sp, #5100-18 ;set new sp so we can pop the other registers faster
exx
pop hl
pop de
pop bc
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af

ld sp, (#5000)

block_main
endm

macro load_reg3 ;load registers for bank 3
block_registers

ld (#6000), sp

ld sp, #6100-18 ;set new sp so we can pop the other registers faster
exx
pop hl
pop de
pop bc
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af

ld sp, (#6000)

block_main
endm

macro bank_0to1
;copy block 0 to 4
block_4
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;copy block 3 to 7 via 0 (corrupts block 0)
ld hl, ramlam
ld de, RAM_LAM
ld bc, ramlam_end - ramlam
ldir
block_7
call RAM_LAM

;copy block 1 to 5 via 0 (corrupts block 0)
block_main
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir
block_5
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;restore block 0
block_4
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 2 to 6
block_6
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

block_main
endm

macro bank_0to2
;copy block 0 to 8
block_8
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;copy block 3 to 11 via 0 (corrupts block 0)
ld hl, ramlam
ld de, RAM_LAM
ld bc, ramlam_end - ramlam
ldir
block_11
call RAM_LAM

;copy block 1 to 9 via 0 (corrupts block 0)
block_main
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir
block_9
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;restore block 0
block_8
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 2 to 10
block_10
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

block_main
endm

macro bank_0to3
;copy block 0 to 12
block_12
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;copy block 3 to 15 via 0 (corrupts block 0)
ld hl, ramlam
ld de, RAM_LAM
ld bc, ramlam_end - ramlam
ldir
block_15
call RAM_LAM

;copy block 1 to 13 via 0 (corrupts block 0)
block_main
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir
block_13
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;restore block 0
block_12
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 2 to 14
block_14
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

block_main
endm

macro bank_1to0
;copy block 5 to 1 via 0
block_5
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir
block_main
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;copy block 4 to 0
block_4
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 6 to 2
block_6
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

;copy block 7 to 3, LOSES STACK
block_7
ld hl, #4000
ld de, #c000
ld bc, #4000
ldir
endm

macro bank_2to0
;copy block 9 to 1 via 0
block_9
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir
block_main
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;copy block 8 to 0
block_8
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 10 to 2
block_10
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

;copy block 11 to 3 LOSES STACK
block_11
ld hl, #4000
ld de, #c000
ld bc, #4000
ldir
endm

macro bank_3to0
;copy block 13 to 1 via 0
block_13
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir
block_main
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir

;copy block 12 to 0
block_12
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 14 to 2
block_10
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

;copy block 15 to 3 LOSES STACK
block_11
ld hl, #4000
ld de, #c000
ld bc, #4000
ldir
endm

; CPC ROM header
               
defb 1 ; background ROM
defb 1 ; mark
defb 0 ; version
defb 0 ; modification

defw rsx_names

; RSX jumpblock

jp rom_init

; general

jp rsx_help
jp rsx_1
jp rsx_2
jp rsx_3

rsx_names: defb 'FLIPP', 'Y'+#80

defb 'FLIPPYHEL', 'P'+#80
defb '1'+#80
defb '2'+#80
defb '3'+#80

defb 0

; --------------------------------------------------

; help for RSXs are in the order that we want to display the entire online help

hlp_all:

hlp_help: defb '|flippyhelp - Displays online help.', 0
hlp_1: defb '|1 - Change to task 1.', 0
hlp_2: defb '|2 - Change to task 2.', 0
hlp_3: defb '|3 - Change to task 3.', 0

defb 0 ; terminator for |help

; system statuses & messages

msg_signon: defb ' FLIPPY V0.9 ROM BY VORAX 2025', 0
msg_version: defb '0.9', 0
msg_newline: defb 13, 10, 0

rom_init: di
ld a,(#8000) ;skip initialisation if not the first block
cp 1 ;as we don't want to get into an infinite loop
jp nz, init_end ;#8000 is used not #be80 as #8000 is zeroed out by
;the boot process

;#be80 is used to know which current bank we are in
;currently use bank 4 for register preservation & rom state

;for |3
ld a,3
ld (#be80), a
bank_0to3
save_reg3

;for |2
ld a,2
ld (#be80), a
bank_0to2
save_reg2

;for |1
ld a,1
ld (#be80), a
bank_0to1
save_reg1

init_end:
push af
push bc
push de
push hl

xor a
ld (#8000), a

ld hl, msg_signon ; signon
call str_output

ld hl, msg_newline
call str_output

pop hl
pop de
pop bc
pop af

ei
ret

rsx_1: di
push af
push bc

ld a,(#be80)
cp 2
jp z, rsx_1store2
cp 3
jp z, rsx_1store3

pop bc
pop af
ei
ret

rsx_1store2:
pop bc
pop af
save_reg2
bank_0to2
jp rsx_1end

rsx_1store3:
pop bc
pop af
save_reg3
bank_0to3

rsx_1end: bank_1to0
load_reg1
ei
ret

rsx_2: di
push af
push bc

ld a,(#be80)
cp 1
jp z, rsx_2store1
cp 3
jp z, rsx_2store3

pop bc
pop af
ei
ret

rsx_2store1:
pop bc
pop af
save_reg1
bank_0to1
jp rsx_2end

rsx_2store3:
pop bc
pop af
save_reg3
bank_0to3

rsx_2end: bank_2to0
load_reg2
ei
ret

rsx_3: di
push af
push bc

ld a,(#be80)
cp 1
jp z, rsx_3store1
cp 1
jp z, rsx_3store2

pop bc
pop af
ei
ret

rsx_3store1:
pop bc
pop af
save_reg1
bank_0to1
jp rsx_3end

rsx_3store2:
pop bc
pop af
save_reg2
bank_0to2

rsx_3end: bank_3to0
load_reg3
ei
ret

; ------------------------- display help

rsx_help: and a
jr z, fn_help
               
ld hl, hlp_help
jp str_outputln

fn_help: ld hl, hlp_all
fn_help_lp: ld a, (hl)
and a
ret z ; no more help
call str_outputln
inc hl
jr fn_help_lp

; ------------------------- ramlam

ramlam:
; TODO: disable upper rom
ld hl, #c000
ld de, #4000
ld bc, #4000
ldir
; TODO: enable upper rom
ret
ramlam_end:

; ------------------------- string output - no interrupts?
; -- parameters:
; -- HL = zero terminated string
; -- return:
; --
; -- corrupt:
; -- AF, HL

str_output: ld a, (hl)
and a
ret z
call TXT_OUT_CHAR
inc hl
jr str_output

; ------------------------- string output and a newline - no interrupts?
; -- parameters:
; -- HL = zero terminated string
; -- return:
; --
; -- corrupt:
; -- AF, HL

str_outputln:
call str_output
push hl
ld hl, msg_newline
call str_output
pop hl
ret



Any thoughts?

zhulien

#29
fixed quite a few things, search for TODO to see what there is TODO

How is the best way to get the current state of the upper and lower ROMS and re-enable them without firmware?

I wreckon someone smarter than me could have this running in 20 minutes :D

zhulien

Someone suggested ROM space is a good place to put maths functions - because... likely you can store lots of precalculated tables.

Some ideas for inclusion within a MATHS ROM which lots of future programs 'could' use.

- multiplication tables, integer
- division tables, integer
- remainder tables, integer
- sin, cos, tan
- matrix transformations using table lookups

are float functions worth putting in also? i guess why not put the best ones available.  The good thing about a standard MATHS rom, it would behave like an Amiga library or a Windows DLL, when better routines get put in, software gets faster.

andycadley

Quote from: zhulien on 14:57, 26 February 25Today on the way home from work, I was thinking, I have lots of RAM on my CPC, why can't i run lots of BASICs at the same time.

Now, this is far from doing that, but as an initial POC, I was thinking, from memory there is nothing stored in the OS ROMs that do anything with banking, so... we should in theory be able to store lots of the first 64kb into the other banks, and swap between them.  To make it "safer" for now, to avoid e.g. keyboard presses to swap tasks, we could use RSXs, like |1, |2, |3 (first 192kb of 256kb memory expansion).  the 4th bank first block initially to preserve the registers and anything else we may need to preserve.


I'm not sure you'd really need to preserve the registers, since RSX's by definition don't so presumably the ROM calling code is good as it is. And interrupts will presumably always be enabled. The Stack pointer would need preserving, but I think that's about it.

The trickiest part would be juggling ROM/RAM usage around to be able to copy all 64K around, but that shouldn't be insurmountable (I'm not sure I've had enough coffee or thinking time to convince myself of the best approach).

andycadley

Quote from: zhulien on 15:42, 26 February 25Someone suggested ROM space is a good place to put maths functions - because... likely you can store lots of precalculated tables.

Some ideas for inclusion within a MATHS ROM which lots of future programs 'could' use.

- multiplication tables, integer
- division tables, integer
- remainder tables, integer
- sin, cos, tan
- matrix transformations using table lookups

are float functions worth putting in also? i guess why not put the best ones available.  The good thing about a standard MATHS rom, it would behave like an Amiga library or a Windows DLL, when better routines get put in, software gets faster.
I think this could be a great idea. Especially if clear machine code entry points were provided as well as RSX entry points (so that it could be used in cartridges that don't include the firmware). And as long as people don't license it up the wazoo with GPL and such.

zhulien

Quote from: andycadley on 15:58, 26 February 25
Quote from: zhulien on 14:57, 26 February 25Today on the way home from work, I was thinking, I have lots of RAM on my CPC, why can't i run lots of BASICs at the same time.

Now, this is far from doing that, but as an initial POC, I was thinking, from memory there is nothing stored in the OS ROMs that do anything with banking, so... we should in theory be able to store lots of the first 64kb into the other banks, and swap between them.  To make it "safer" for now, to avoid e.g. keyboard presses to swap tasks, we could use RSXs, like |1, |2, |3 (first 192kb of 256kb memory expansion).  the 4th bank first block initially to preserve the registers and anything else we may need to preserve.


I'm not sure you'd really need to preserve the registers, since RSX's by definition don't so presumably the ROM calling code is good as it is. And interrupts will presumably always be enabled. The Stack pointer would need preserving, but I think that's about it.

The trickiest part would be juggling ROM/RAM usage around to be able to copy all 64K around, but that shouldn't be insurmountable (I'm not sure I've had enough coffee or thinking time to convince myself of the best approach).
The juggling is already coded there, i am in the process of testing now, it is copying the ROM content though as the ROM is enabled.  I created my own ramlam sort of, it copies a small routing from ROM into RAM to disable ROMs and copy the screen RAM, but... still i have to figure out how to disable and enable the ROMs.

zhulien

#34
fixed the RAMLAMs other than the rom disabling/enabling

; TODO:
; honor lower ROM enabling
; enable and disable upper ROM in the ramlam function
; preserve initial registers correctly (including alternate and SP)
;
;FUTURE:
; can we fit a |4 within the 256kb extra RAM?
; perhaps support 128kb machines with memory swap-in-place
; dynamically detect memory sizes
; don't use macros? but we have plenty of ROM space for now

TXT_OUT_CHAR equ #bb5a
RAM_LAM_0000 equ #8000 ; above lower ROM and below upper ROM, copies RAM under lower ROM
RAM_LAM_C000 equ #8100 ; above lower ROM and below upper ROM, copies RAM under upper ROM

org #c000

;write direct -1,1,#C0

macro block_main
push bc
ld bc,  #7fc0
out (c), c
pop bc
endm

macro block_1_0
ld bc,  #7fc4
out (c), c
endm

macro block_1_1
ld bc,  #7fc5
out (c), c
endm

macro block_1_2
ld bc,  #7fc6
out (c), c
endm

macro block_1_3
ld bc,  #7fc7
out (c), c
endm

macro block_2_0
ld bc,  #7fcc
out (c), c
endm

macro block_2_1
ld bc,  #7fcd
out (c), c
endm

macro block_2_2
ld bc,  #7fce
out (c), c
endm

macro block_2_3
ld bc,  #7fcf
out (c), c
endm

macro block_3_0
ld bc,  #7fd4
out (c), c
endm

macro block_3_1
ld bc,  #7fd5
out (c), c
endm

macro block_3_2
ld bc,  #7fd6
out (c), c
endm

macro block_3_3
ld bc,  #7fd7
out (c), c
endm

macro block_registers
push bc
ld bc,  #7fdc
out (c), c
pop bc
endm

macro save_reg1 ;save registers for bank 1
block_registers

ld (#4000), sp

ld sp, #4100 ;set new sp so we can push the other registers faster
push af
push bc
push de
push hl
push ix
push iy
exx
push bc
push de
push hl
exx

ld sp, (#4000)

block_main
endm

macro save_reg2 ;save registers for bank 2
block_registers

ld (#5000), sp

ld sp, #5100 ;set new sp so we can push the other registers faster
push af
push bc
push de
push hl
push ix
push iy
exx
push bc
push de
push hl
exx

ld sp, (#5000)

block_main
endm

macro save_reg3 ;save registers for bank 3
block_registers

ld (#6000), sp

ld sp, #6100 ;set new sp so we can push the other registers faster
push af
push bc
push de
push hl
push ix
push iy
exx
push bc
push de
push hl
exx

ld sp, (#6000)

block_main
endm

macro load_reg1 ;load registers for bank 1
block_registers

ld (#4000), sp

ld sp, #4100-18 ;set new sp so we can pop the other registers faster
exx
pop hl
pop de
pop bc
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af

ld sp, (#4000)

block_main
endm

macro load_reg2 ;load registers for bank 2
block_registers

ld (#5000), sp

ld sp, #5100-18 ;set new sp so we can pop the other registers faster
exx
pop hl
pop de
pop bc
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af

ld sp, (#5000)

block_main
endm

macro load_reg3 ;load registers for bank 3
block_registers

ld (#6000), sp

ld sp, #6100-18 ;set new sp so we can pop the other registers faster
exx
pop hl
pop de
pop bc
exx
pop iy
pop ix
pop hl
pop de
pop bc
pop af

ld sp, (#6000)

block_main
endm

macro bank_0to1
;copy block 0_2 to 1_2
block_1_2
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;copy ramlams into 0_2 (corrupts block 0_2)
ld hl, ramlam_l
ld de, RAM_LAM_0000
ld bc, ramlam_l_end - ramlam_l
ldir

ld hl, ramlam_h
ld de, RAM_LAM_C000
ld bc, ramlam_h_end - ramlam_h
ldir

;copy block 0_0 to 1_0
block_1_0
call RAM_LAM_0000

;copy block 0_3 to 1_3
block_1_3
call RAM_LAM_C000

;copy block 0_1 to 1_1 via into 0_2 (corrupts block 0_2)
block_main
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir
block_1_1
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;restore block 0_2
block_1_2
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

block_main
endm

macro bank_0to2
;copy block 0_2 to 2_2
block_2_2
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;copy ramlams into 0_2 (corrupts block 0_2)
ld hl, ramlam_l
ld de, RAM_LAM_0000
ld bc, ramlam_l_end - ramlam_l
ldir

ld hl, ramlam_h
ld de, RAM_LAM_C000
ld bc, ramlam_h_end - ramlam_h
ldir

;copy block 0_0 to 2_0
block_2_0
call RAM_LAM_0000

;copy block 0_3 to 2_3
block_2_3
call RAM_LAM_C000

;copy block 0_1 to 2_1 via into 0_2 (corrupts block 0_2)
block_main
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir
block_2_1
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;restore block 0_2
block_2_2
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

block_main
endm

macro bank_0to3
;copy block 0_2 to 3_2
block_3_2
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;copy ramlams into 0_2 (corrupts block 0_2)
ld hl, ramlam_l
ld de, RAM_LAM_0000
ld bc, ramlam_l_end - ramlam_l
ldir

ld hl, ramlam_h
ld de, RAM_LAM_C000
ld bc, ramlam_h_end - ramlam_h
ldir

;copy block 0_0 to 3_0
block_3_0
call RAM_LAM_0000

;copy block 0_3 to 3_3
block_3_3
call RAM_LAM_C000

;copy block 0_1 to 3_1 via into 0_2 (corrupts block 0_2)
block_main
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir
block_3_1
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;restore block 0_2
block_3_2
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

block_main
endm

; no need for RAMLAMs here because all writes to ROM go to underlying RAM
macro bank_1to0
;copy block 5 to 1 via 2
block_1_1
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir
block_main
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;copy block 4 to 0
block_1_0
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 6 to 2
block_1_2
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

;copy block 7 to 3, LOSES STACK
block_1_3
ld hl, #4000
ld de, #c000
ld bc, #4000
ldir
endm

; no need for RAMLAMs here because all writes to ROM go to underlying RAM
macro bank_2to0
;copy block 9 to 1 via 2
block_2_1
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir
block_main
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;copy block 8 to 0
block_2_0
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 10 to 2
block_2_2
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

;copy block 11 to 3 LOSES STACK
block_2_3
ld hl, #4000
ld de, #c000
ld bc, #4000
ldir
endm

; no need for RAMLAMs here because all writes to ROM go to underlying RAM
macro bank_3to0
;copy block 13 to 1 via 2
block_3_1
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir
block_main
ld hl, #8000
ld de, #4000
ld bc, #4000
ldir

;copy block 12 to 0
block_3_0
ld hl, #4000
ld de, #0000
ld bc, #4000
ldir

;copy block 14 to 2
block_2_2
ld hl, #4000
ld de, #8000
ld bc, #4000
ldir

;copy block 15 to 3 LOSES STACK
block_2_3
ld hl, #4000
ld de, #c000
ld bc, #4000
ldir
endm

; CPC ROM header
               
defb 1 ; background ROM
defb 1 ; mark
defb 0 ; version
defb 0 ; modification

defw rsx_names

; RSX jumpblock

jp rom_init

; general

jp rsx_help
jp rsx_1
jp rsx_2
jp rsx_3

rsx_names: defb 'FLIPP', 'Y'+#80

defb 'FLIPPYHEL', 'P'+#80
defb '1'+#80
defb '2'+#80
defb '3'+#80

defb 0

; --------------------------------------------------

; help for RSXs are in the order that we want to display the entire online help

hlp_all:

hlp_help: defb '|flippyhelp - Displays online help.', 0
hlp_1: defb '|1 - Change to task 1.', 0
hlp_2: defb '|2 - Change to task 2.', 0
hlp_3: defb '|3 - Change to task 3.', 0

defb 0 ; terminator for |help

; system statuses & messages

msg_signon: defb ' FLIPPY V0.9 ROM BY VORAX 2025', 0
msg_version: defb '0.9', 0
msg_newline: defb 13, 10, 0
msg_task1: defb 'Task 1', 0
msg_task2: defb 'Task 2', 0
msg_task3: defb 'Task 3', 0

rom_init: di
push af
push bc
push de
push hl

ld a,(#8000) ;skip initialisation if not the first block
cp 1 ;as we don't want to get into an infinite loop
jp nz, init_end ;#8000 is used not #be80 as #8000 is zeroed out by
;the boot process

;#be80 is used to know which current bank we are in
;currently use bank 4 for register preservation & rom state

;for |3
ld a,3
ld (#be80), a
bank_0to3
save_reg3

;for |2
ld a,2
ld (#be80), a
bank_0to2
save_reg2

;for |1
ld a,1
ld (#be80), a
bank_0to1
save_reg1

init_end:
xor a
ld (#8000), a

ld hl, msg_signon
call str_output

ld hl, msg_newline
call str_output

pop hl
pop de
pop bc
pop af

ei
ret

rsx_1: di
push af
push bc
push de
push hl

ld a,(#be80)
cp 2
jp z, rsx_1store2
cp 3
jp z, rsx_1store3

pop hl
pop de
pop bc
pop af
ei
ret

rsx_1store2:
pop hl
pop de
pop bc
pop af
save_reg2
bank_0to2
jp rsx_1end

rsx_1store3:
pop hl
pop de
pop bc
pop af
save_reg3
bank_0to3

rsx_1end: bank_1to0
load_reg1

push af
push hl
ld hl, msg_task1
call str_output

ld hl, msg_newline
call str_output
pop hl
pop af

ei
ret

rsx_2: di
push af
push bc
push de
push hl

ld a,(#be80)
cp 1
jp z, rsx_2store1
cp 3
jp z, rsx_2store3

pop hl
pop de
pop bc
pop af
ei
ret

rsx_2store1:
pop hl
pop de
pop bc
pop af
save_reg1
bank_0to1
jp rsx_2end

rsx_2store3:
pop hl
pop de
pop bc
pop af
save_reg3
bank_0to3

rsx_2end: bank_2to0
load_reg2

push af
push hl
ld hl, msg_task2
call str_output

ld hl, msg_newline
call str_output
pop hl
pop af

ei
ret

rsx_3: di
push af
push bc
push de
push hl

ld a,(#be80)
cp 1
jp z, rsx_3store1
cp 2
jp z, rsx_3store2

pop hl
pop de
pop bc
pop af
ei
ret

rsx_3store1:
pop hl
pop de
pop bc
pop af
save_reg1
bank_0to1
jp rsx_3end

rsx_3store2:
pop hl
pop de
pop bc
pop af
save_reg2
bank_0to2

rsx_3end: bank_3to0
load_reg3

push af
push hl
ld hl, msg_task3
call str_output

ld hl, msg_newline
call str_output
pop hl
pop af

ei
ret

; ------------------------- display help

rsx_help: and a
jr z, fn_help
               
ld hl, hlp_help
jp str_outputln

fn_help: ld hl, hlp_all
fn_help_lp: ld a, (hl)
and a
ret z ; no more help
call str_outputln
inc hl
jr fn_help_lp

; ------------------------- ramlam

ramlam_l:
; TODO: disable lower rom
ld hl, #0000
ld de, #4000
ld bc, #4000
ldir
; TODO: enable lower rom
ret
ramlam_l_end:

ramlam_h:
; TODO: disable upper rom
ld hl, #c000
ld de, #4000
ld bc, #4000
ldir
; TODO: enable upper rom
ret
ramlam_h_end:

; ------------------------- string output - no interrupts?
; -- parameters:
; -- HL = zero terminated string
; -- return:
; --
; -- corrupt:
; -- AF, HL

str_output: ld a, (hl)
and a
ret z
call TXT_OUT_CHAR
inc hl
jr str_output

; ------------------------- string output and a newline - no interrupts?
; -- parameters:
; -- HL = zero terminated string
; -- return:
; --
; -- corrupt:
; -- AF, HL

str_outputln:
call str_output
push hl
ld hl, msg_newline
call str_output
pop hl
ret


andycadley

Quote from: zhulien on 16:07, 26 February 25The juggling is already coded there, i am in the process of testing now, it is copying the ROM content though as the ROM is enabled.  I created my own ramlam sort of, it copies a small routing from ROM into RAM to disable ROMs and copy the screen RAM, but... still i have to figure out how to disable and enable the ROMs.

But when an RSX is called the ROM state should already be known, your ROM will be the active upper ROM and I think the Lower ROM is always paged in (may need to verify that). So you don't need to record how they were set as long as you put your ROM back in the foreground.

It may be possible to do the copying without every having to put a routine in RAM, although it may not be worth it.

zhulien

let's say i use the firmware,  do i need to search for my own ROM so i can reenable it with the right ROM number?

zhulien


yes, you can use the firmware RAMLAM, but that will be slow as it is per byte.  I juggle the memory around so i can do it in LDIRs of 16kb at a time, it's very fast - of course a bit buggy for now (ROMS always enabled to start).  I will resume tomorrow or another day, 3am here

zhulien

#38
I just finished coding Home Computer JavaScript over the weekend.

Enjoy!!!

https://www.cpcwiki.eu/forum/off-topic/home-computer-javascript/ (in offtopic, but I will make it relevant to CPC soon)

About 50 commands with Locomotive BASIC inspired JavaScript environment.  Create any JS (only for now) program you like as if you were using a modern CPC that used JavaScript.

CPC-like API coming soon! inspired by Locomotive BASIC!

http://8bitology.com/

I even got WhatsApp to create a hangman game for you to play in it.

next to create some libraries to make coding easier.

zhulien

Thanks, I have now put the code for Open Home Computer JS into github for those who want to self-host or host at home for their xbox ones.

https://github.com/PrimalNinja/ohcjs

zhulien

RC4 available, you can now edit more than one file at once.

zhulien

#41
RC5 online, RC4 in github.

http://8bitology.com/
https://github.com/PrimalNinja/ohcjs

added support for the following human languages: chinese (simplified), chinese (traditional), english, french, german, indonesian, klingon (limited), russian, spanish, tagalog

please kindly give me some feedback if you speak one of those languages.

zhulien

languages now: arabic, chinese, chineset, czech, english, french, german, greek, hindi, italian, japanese, javanese, klingon (limited), korean, russian, spanish, tagalog, thai, vietnamese

zhulien

#43
I'm all languaged out...

arabic, chinese, chineset, czech, dutch, english, french, german, greek, hebrew, hindi, italian, japanese, javanese, klingon, korean, persian, polish, portuguese, romanian, russian, spanish, swahili, swedish, tagalog, thai, turkish, vietnamese

i spent a lot of time to make the RTL languages work correctly, very interesting exercise.


Powered by SMFPacks Menu Editor Mod