Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions code/Z80_rom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Compiled Object files
*.o
*.obj

# Executables
*.bin
*.elf
src/LSTDex
bin/
#.vscode/
.cache/
__pycache__/
libarduinoSTL/
libarduino/
*.ini
.d/
pkg/
*.tar.gz
*.pkg.tar.zst
l61/
.ccls-cache/
.kdev4/
*.lex61
/data
l61bs.kdev4
.idea/
.run/
out.asm
*.sym
/.vscode
674 changes: 674 additions & 0 deletions code/Z80_rom/LICENSE

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions code/Z80_rom/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
#Copyright (C) 2024 tete
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <https://www.gnu.org/licenses/>.
#


BUILD_DIR := build
# Directories containing source files
SRC_DIR = src
SRC_DIRS += $(SRC_DIR) $(wildcard $(SRC_DIR)/**)

SRC_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.*))

AS = pasmo

NAME = zsys_ctl
ROM = ${NAME}.bin
PRE_ROM = ${NAME}.pram.bin
FIXED_RAM_IMG = ${NAME}.fixed.bin

all: rom

default: rom
rom: ${ROM}

clean:
rm -r ${ROM} ${FIXED_RAM_IMG} ${PRE_ROM} ${PRE_ROM}.sym out.asm

out.asm:
bash ./makebigasm ${SRC_FILES}

$(PRE_ROM): out.asm
${AS} -I ./src --bin out.asm ${PRE_ROM} ${PRE_ROM}.sym

$(FIXED_RAM_IMG): $(PRE_ROM)
dd skip=512B if=${PRE_ROM} of=${FIXED_RAM_IMG} &> /dev/null

$(ROM): ${FIXED_RAM_IMG}
${AS} -I . --bin z80_bootloader.asm ${ROM} zbootloader.sym
28 changes: 28 additions & 0 deletions code/Z80_rom/makebigasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/env bash

if [[ -e "out.asm" ]]; then
rm "out.asm"
fi

touch out.asm
for item in $@; do
if [ ! -e "$item" ]; then
echo "File \"$item\" not exists"
exit 1
fi

echo -e "\n; start of $item\n" >> out.asm
cat $item >> out.asm

echo -e "\n; end of $item\n" >> out.asm
done

cat >> out.asm <<_ACEOF

; injeced code
if $ >= 484+512
.error "ram code to big"
endif
; end injeced code

_ACEOF
57 changes: 57 additions & 0 deletions code/Z80_rom/src/helper_mac.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmp MACRO opt1, opt2
;ld ($+4), a
ld a, opt1
;jr $+2
;db 0
cp opt2
;jr $+4
ENDM

jeq macro adder
jp z, adder
endm

block macro n, val
rept n
db val
endm
endm

macro reqcall
call reqsys
endm

jneq macro adder
jp nz, adder
endm

calleq macro adder
call z, adder
endm

callneq macro adder
call nz, adder
endm

retneq macro
ret nz
endm

reteq macro
ret z
endm

word macro ...
dw ...
endm

defval macro dname, dval
dname macro
dval
endm
endm

stackld macro to, from
push from
pop to
endm
49 changes: 49 additions & 0 deletions code/Z80_rom/src/main.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
MAIN_CPU_POWER_REG equ 0xFC
MORE_WORK_READY_FLAG equ 0xCC
POWER_OFF_FLAG equ 0xC1
TODO_MAIN_MEM_START_ADDER equ 0xCC

org 0x00
boot_vec:
db 0
;rom_metadata:
; db "tete", 0
; db 4
; db "z80 ctl ROM and mem-man", 0
; db 23


org 0x200
work_buff:
block (256/2), 0x00
ret

z80_start_ram equ work_buff

__start:
ld bc, TODO_MAIN_MEM_START_ADDER
call mem_setup
cmp b, 1

jeq cpu_start_up
jneq run_loop

ld a, 45
ld bc, 0x455

cpu_start_up:
ld hl, MAIN_CPU_POWER_REG
ld (hl), b

run_loop:
cmp (MORE_WORK_READY_FLAG), 1; *(MORE_WORK_READY_FLAG) == true

calleq work_buff

jr run_loop
start_error:
halt
jr start_error

mem_setup: ;todo
ret
47 changes: 47 additions & 0 deletions code/Z80_rom/src/reqsys.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
MEMCPY_REQ_CODE equ 15
SET_MEM_BANK_REQ_CODE equ 5

reqsys:
push de
push hl

cmp a, MEMCPY_REQ_CODE ; if b == MEMCPY_REQ_CODE then
calleq memcpy_task ; memcpy_task()
cmp a, SET_MEM_BANK_REQ_CODE ; eles if b == SET_MEM_BANK_REQ_COD then
calleq set_mem_bank_task ; set_mem_bank_task()
; endif

cmp a, 1
jeq reset_req_on_ret
jneq reqsys_end

reset_req_on_ret
pop hl
pop de

reqsys_end:
ret

req_arg_a:
dw 0

req_arg_b:
dw 0

req_arg_c:
dw 0

memcpy_task:
pop hl
pop de
lddr

ld a, 0

push de
pop bc
ret

set_mem_bank_task:
nop ; TODO
ret
32 changes: 32 additions & 0 deletions code/Z80_rom/z80_bootloader.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
include "src/helper_mac.inc"
include "zsys_ctl.pram.bin.sym"
RAM_IMG_LEN equ (end_ram_img-ram_img)

cpu_bank EQU 00CA0H
end_cpu_bank EQU 00D20H

org 0x0
__boot:
ld bc, RAM_IMG_LEN
ld de, z80_start_ram
ld hl, ram_img
lddr

ld a, 0
ld bc, 0
ld de, 0
ld hl, 0
jp __start

E1:
halt
jr E1
db "R"
ram_img:
incbin "zsys_ctl.fixed.bin"
end_ram_img:


if $ >= 0x200
.error "ram_img to big"
endif
16 changes: 0 additions & 16 deletions code/ros-z80-fw/.gitignore

This file was deleted.

Loading