Skip to content

Commit

Permalink
Some build fixes, GW proto, own CP/M programs
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Oct 5, 2024
1 parent 1886d27 commit 76b3e9e
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/serial.raw
/runme.bin
/cpm.dsk
/buildinfo_inc.asm
3 changes: 0 additions & 3 deletions 8080/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions 8080/Makefile

This file was deleted.

16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,23 @@ cpu_tables.inc: cpu_gen_tables.py
rm -f cpu_tables.inc
./cpu_gen_tables.py > $@

apps/*.com:
$(MAKE) -C apps

cpm/bios.inc cpm/cpm22.inc cpm/bios.bin cpm/cpm22.bin:
$(MAKE) -C cpm

%.o: %.asm $(ALL_DEPENDS) $(INCLUDES)
$(CA65) $(CA65_OPTS) --listing $(<:.asm=.lst) -o $@ $<

main.o: 8080/*.com 8080/mbasic-real.com

$(PRG): $(OBJECTS) $(LD65_CFG) $(ALL_DEPENDS)
$(LD65) $(LD65_OPTS) -o $@ $(OBJECTS)
@echo "Linking ..."
echo ".BYTE \"MEGA/80 built on `uname -s` by `whoami`@`uname -n` at `date`\"" > buildinfo_inc.asm
$(CA65) $(CA65_OPTS) -o buildinfo.o buildinfo.asm
$(LD65) $(LD65_OPTS) -o $@ $(OBJECTS) buildinfo.o

cpm.dsk: diskdefs apps/*.com $(ALL_DEPENDS)
$(MAKE) -C apps/
$(MAKE) -C apps
rm -f $@
mkfs.cpm -f mega65 $@
cpmcp -f mega65 $@ dist/cpm-apps/* 0:
Expand All @@ -83,12 +87,12 @@ dist: $(DISK_IMAGE)
cp emu.d81 dist/bin/mega65.d81

clean:
$(RM) -f $(PRG) *.o *.lst $(DISK_IMAGE) $(MAP_FILE) runme.bin cpm.dsk
$(RM) -f $(PRG) *.o *.lst $(DISK_IMAGE) $(MAP_FILE) runme.bin cpm.dsk buildinfo_inc.asm
$(MAKE) -C cpm clean
$(MAKE) -C apps clean

distclean:
$(MAKE) clean
$(RM) -f 8080/*.com uart.sock dump.mem serial.raw
$(RM) -f uart.sock dump.mem serial.raw

.PHONY: all clean distclean xemu ethertest dist
14 changes: 14 additions & 0 deletions apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# My own CP/M programs

Beware: some/all of them only works with MEGA/80 as it uses the special
MEGA65 gateway calls, to interact with the native code side of MEGA/80.

## SHUTDOWN.COM

After a confirmation question shuts down the system to get you at the
MEGA65 BASIC prompt without the need of RESETing the a computer.

## CPMVER.COM

Gives information about the CP/M system and MEGA/80

98 changes: 98 additions & 0 deletions apps/cpmver.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
; **** fragments of this is from my old project in 2017, thus is a huge mess ****
; Little CP/M utility to display CP/M version and
; some information, to test my emulator.
; [OLD-COMMENT Note: currently it's coded in an odd way, to]
; [OLD-COMMENT bridge problems present in my 8080 emulator.]

ORG 0x100

LD HL, (6)
LD SP, HL
PUSH HL

LD A, 2 ; function 2: get info string into DMA
CALL $FFFF
LD HL,0x80 ; using the DMA
CALL print_string


LD HL,text1
CALL print_string

POP HL
CALL print_hex_word

LD HL, text2
CALL print_string
LD HL, (1)
CALL print_hex_word

LD HL,text3
CALL print_string

LD C,12 ; BDOS function, get version number
CALL 5
PUSH HL
LD A,H
CALL print_hex_byte

LD HL,text4
CALL print_string
POP HL
LD A,L
CALL print_hex_byte

JP 0 ; WBOOT, end of program


text1: DB 13,10,"BDOS at ",0
text2: DB ", BIOS at ",0
text3: DB ", CP/M system is ",0
text4: DB ", CP/M version is ",0


print_string:
LD A,(HL)
OR A
RET Z
INC HL
CALL print_char
JP print_string

print_hex_word:
PUSH HL
LD A,H
CALL print_hex_byte
POP HL
LD A,L
print_hex_byte:
PUSH AF
RRCA
RRCA
RRCA
RRCA
CALL print_hex_nib
POP AF
print_hex_nib:
AND 15
LD B,0
LD C,A
LD HL,hextab
ADD HL,BC
LD A,(HL)
print_char:
PUSH AF
PUSH BC
PUSH DE
PUSH HL
LD E,A
LD C,2
CALL 5
POP HL
POP DE
POP BC
POP AF
RET

hextab:
DB '0123456789ABCDEF'
Binary file added apps/cpmver.com
Binary file not shown.
8 changes: 8 additions & 0 deletions buildinfo.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.CODE


.EXPORT build_info_str
build_info_str:
.INCLUDE "buildinfo_inc.asm"
.BYTE 0

24 changes: 23 additions & 1 deletion console.asm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ ring_the_bell: .RES 1
; and speed sensitive part (i8080 emulation). So there is huge amount room here for more sane
; and optimized solution!


; Purpose: reset console state, for future escape sequences and like that
.EXPORT console_state_reset
.PROC console_state_reset
RTS
.ENDPROC


; Currently we don't handle colours etc anything, but full colour RAM anyway with a consistent colour
.EXPORT clear_screen
.PROC clear_screen
Expand Down Expand Up @@ -413,6 +421,18 @@ sprite_shaper2:
PHY
PHZ

; Test for BRK
TSX
LDA $105,X
AND #$10
BEQ notbrk


INC $D020

;JMP eoi

notbrk:
; --- KEYBOARD scanning with $D610 ---
LDA key_queued
BNE @already_has ; avoid scanning, if there is already a character extracted to kbd_queued
Expand Down Expand Up @@ -540,11 +560,13 @@ sprite_shaper2:



ASL $D019 ; acknowledge VIC interrupt (note: it wouldn't work on a real C65 as RMW opcodes are different but it does work on M65 as on C64 too!)

eoi:
PLZ
PLY
PLX
PLA
ASL $D019 ; acknowledge VIC interrupt (note: it wouldn't work on a real C65 as RMW opcodes are different but it does work on M65 as on C64 too!)
RTI

hextab:
Expand Down
1 change: 1 addition & 0 deletions console.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
.IMPORT reg_dump
.IMPORT conin_check_status
.IMPORT conin_get_with_wait
.IMPORT console_state_reset


.MACRO WRISTR str
Expand Down
2 changes: 1 addition & 1 deletion disk.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
.EXPORTZP disk_sector
.EXPORTZP disk_track

cpm_dma: .RES 2
cpm_dma: .RES 4 ; 4 bytes, as we may use it with 32 bit addressing
disk_sector: .RES 2
disk_track: .RES 2

Expand Down
13 changes: 13 additions & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ bios_call_table:
.PROC go_cpm
LDA #$80
STA cpm_dma
LDA #I8080_BANK
STA cpm_dma+2
LDA #$00
STA cpm_dma+1
STA cpm_dma+3
STA cpu_c ; C=0 -> drive number [with multiple drives it won't preserve current drive this way!]
; Routine M65BIOS_GO_CPM will set up the BIOS and BDOS "JP" opcodes on CP/M zero page and execute CBASE (CCP)
LDA #.LOBYTE(M65BIOS_GO_CPM)
Expand All @@ -128,7 +131,16 @@ bios_call_table:
; --------------------------------------------------------

.PROC BIOS_BOOT
JSR console_state_reset
; Fancy printouts
.IMPORT build_info_str
LDX #0
: LDA build_info_str,X
BEQ :+
JSR write_char
INX
BNE :-
: JSR write_crlf
WRISTR {CPU_EMU_COPYRIGHT,13,10,BIOS_COPYRIGHT,13,10,"CCP and BDOS "}
LDX #0
: LDA bdos_image+8,X ; DR's copyright message inside the BDOS: let's print that out as well!
Expand Down Expand Up @@ -177,6 +189,7 @@ bios_call_table:
; --------------------------------------------------------

.PROC BIOS_WBOOT
JSR console_state_reset
; Copy BDOS/CCP only (not the BIOS itself!)
STA $D707 ; trigger in-line DMA
.BYTE $A,0 ; --- second job --- enhanced mode opts
Expand Down
24 changes: 21 additions & 3 deletions megagw.asm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.INCLUDE "emu.inc"
.INCLUDE "cpu.inc"
.INCLUDE "console.inc"
.INCLUDE "disk.inc"

GW_BUFFER_SIZE = $100

Expand All @@ -49,9 +50,10 @@ gw_buffer: .RES GW_BUFFER_SIZE
ret:
RTS
jump_table:
.WORD shutdown
.WORD get_host_buffer_addr
.WORD hdos_trap
.WORD shutdown ; func 0
.WORD get_host_buffer_addr ; func 1
.WORD get_info_str ; func 2 will use the CP/M dma!!!
.WORD hdos_trap ; func 3
calls = (* - jump_table) / 2
.ENDPROC

Expand Down Expand Up @@ -149,3 +151,19 @@ copy2: .WORD 0 ; target addr
STA $D02F ; VIC KEY register, let's mess it up
JMP ($FFFC)
.ENDPROC


.PROC get_info_str
.IMPORT build_info_str
LDX #0
LDZ #0
: LDA build_info_str,X
STA32Z cpm_dma
BEQ :+
INX
INZ
BRA :-
: CLC
RTS
.ENDPROC

0 comments on commit 76b3e9e

Please sign in to comment.