Updates with more code
This commit is contained in:
parent
e8fa4a2d95
commit
f3f7cd238a
@ -17,7 +17,7 @@
|
||||
; Modified from https://github.com/kloyd/Retro8080/blob/main/funstuff/blinken_pattern.asm
|
||||
; to run in CP/M and with my own pattern.
|
||||
|
||||
ORG 100H
|
||||
ORG 00H
|
||||
INIT LXI H,DATA ; HL points to blinken data
|
||||
SHLD SAVE_HL
|
||||
|
||||
@ -31,7 +31,7 @@ GETD LHLD SAVE_HL ; restore HL
|
||||
|
||||
INPDEL LXI H,0 ; Init HL to zero before starting the delay loop
|
||||
IN 0FFH
|
||||
CPI 00H ; All Sense switches off finishes the program.
|
||||
CPI 01H ; All Sense switches off finishes the program.
|
||||
JZ DONE
|
||||
LXI B,4H ; Hardcoded timer
|
||||
|
||||
@ -45,7 +45,7 @@ BLINK LDAX D
|
||||
; Done with this loop go get the next D
|
||||
|
||||
; Return to CP/M if 00 on sense switches. Some way to drop out.
|
||||
DONE JMP 0H
|
||||
DONE HLT
|
||||
; Somewhere to save HL, since it will get clobbered by the delay routine.
|
||||
SAVE_HL DW 0
|
||||
; Put your pattern list here... this is just jiggy wiggy back forth here.
|
||||
|
605
src/altair8800/cpm/DixMille.asm
Normal file
605
src/altair8800/cpm/DixMille.asm
Normal file
@ -0,0 +1,605 @@
|
||||
; DixeMille.z80 - a Z80 assembly implementation of the dice game Dixe Mille.
|
||||
; Copyright (C) 2023 William R. Moore
|
||||
;
|
||||
; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
ORG 100H
|
||||
|
||||
; Driver logic
|
||||
START
|
||||
; LD SP, STACK
|
||||
LD DE, CLS
|
||||
CALL PRINTS
|
||||
LD DE, HOME
|
||||
CALL PRINTS
|
||||
|
||||
LD DE, WELCOME
|
||||
CALL PRINTS
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
ROLLUNHELD
|
||||
LD DE, STOPROLL
|
||||
CALL PRINTS
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
CALL ROLLTHEMBONES
|
||||
CALL HOLDDICE
|
||||
CALL OUTPUT
|
||||
|
||||
CALL COUNTHELD
|
||||
CP 6
|
||||
JP Z, DONE
|
||||
|
||||
CALL ROLLUNHELD
|
||||
|
||||
DONE
|
||||
JP 00H
|
||||
|
||||
COUNTHELD
|
||||
LD HL, HELD_DICE
|
||||
ADD A, (HL)
|
||||
INC L
|
||||
ADD A, (HL)
|
||||
INC L
|
||||
ADD A, (HL)
|
||||
INC L
|
||||
ADD A, (HL)
|
||||
INC L
|
||||
ADD A, (HL)
|
||||
INC L
|
||||
ADD A, (HL)
|
||||
|
||||
LD L, 0
|
||||
|
||||
RET
|
||||
|
||||
ROLLTHEMBONES
|
||||
LD HL, DICE
|
||||
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
LD A, (HL)
|
||||
POP HL
|
||||
CP 1
|
||||
JP Z, ROLL2
|
||||
CALL ROLL
|
||||
LD DE, DIE1
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
ROLL2
|
||||
INC L
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
LD A, (HL)
|
||||
POP HL
|
||||
CP 1
|
||||
JP Z, ROLL3
|
||||
CALL ROLL
|
||||
LD DE, DIE2
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
ROLL3
|
||||
INC L
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
POP HL
|
||||
CP 1
|
||||
JP Z, ROLL4
|
||||
CALL ROLL
|
||||
LD DE, DIE3
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
ROLL4
|
||||
INC L
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
POP HL
|
||||
CP 1
|
||||
JP Z, ROLL5
|
||||
CALL ROLL
|
||||
LD DE, DIE4
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
ROLL5
|
||||
INC L
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
POP HL
|
||||
CP 1
|
||||
JP Z, ROLL6
|
||||
CALL ROLL
|
||||
LD DE, DIE5
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
ROLL6
|
||||
INC L
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
POP HL
|
||||
CP 1
|
||||
JP Z, ROLLEND
|
||||
CALL ROLL
|
||||
LD DE, DIE6
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
; Return back to original position
|
||||
ROLLEND
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
RET
|
||||
|
||||
HOLDDIE
|
||||
CALL INPUTC
|
||||
CP 00H
|
||||
JP Z, HOLDDIE
|
||||
CP 121
|
||||
JP Z, HOLDDIE_FINISH
|
||||
CP 89
|
||||
JP Z, HOLDDIE_FINISH
|
||||
CP 110
|
||||
JP Z, HOLDDIE_END
|
||||
CP 78
|
||||
JP Z, HOLDDIE_END
|
||||
CALL HOLDDIE
|
||||
HOLDDIE_FINISH
|
||||
LD (HL), 1
|
||||
HOLDDIE_END
|
||||
RET
|
||||
|
||||
; Ask player to hold any dice
|
||||
HOLDDICE
|
||||
LD HL, HELD_DICE
|
||||
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, HD2
|
||||
LD DE, DYWTH
|
||||
CALL PRINTS
|
||||
LD DE, DIE1
|
||||
CALL PRINTS
|
||||
CALL HOLDDIE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
HD2
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, HD3
|
||||
LD DE, DYWTH
|
||||
CALL PRINTS
|
||||
LD DE, DIE2
|
||||
CALL PRINTS
|
||||
CALL HOLDDIE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
HD3
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, HD4
|
||||
LD DE, DYWTH
|
||||
CALL PRINTS
|
||||
LD DE, DIE3
|
||||
CALL PRINTS
|
||||
CALL HOLDDIE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
HD4
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, HD5
|
||||
LD DE, DYWTH
|
||||
CALL PRINTS
|
||||
LD DE, DIE4
|
||||
CALL PRINTS
|
||||
CALL HOLDDIE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
HD5
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, HD6
|
||||
LD DE, DYWTH
|
||||
CALL PRINTS
|
||||
LD DE, DIE5
|
||||
CALL PRINTS
|
||||
CALL HOLDDIE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
HD6
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, HD_DONE
|
||||
LD DE, DYWTH
|
||||
CALL PRINTS
|
||||
LD DE, DIE6
|
||||
CALL PRINTS
|
||||
CALL HOLDDIE
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
HD_DONE
|
||||
; Return back to original position
|
||||
LD L, 0
|
||||
RET
|
||||
|
||||
; Roll the different dice
|
||||
ROLL
|
||||
PUSH BC
|
||||
ROLL_START
|
||||
LD C, 0
|
||||
ROLL_DIE
|
||||
INC C
|
||||
LD A, C
|
||||
CP 7H
|
||||
JP Z, ROLL_START
|
||||
CALL INPUTC
|
||||
CP 00H
|
||||
JP NZ, ROLL_END
|
||||
JP ROLL_DIE
|
||||
ROLL_END
|
||||
LD (HL), C
|
||||
POP BC
|
||||
RET
|
||||
|
||||
; Output the dice results
|
||||
OUTPUT
|
||||
LD HL, DICE
|
||||
|
||||
LD DE, YOUROLLED
|
||||
CALL PRINTS
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
LD DE, DIE1
|
||||
CALL PRINTS
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, MARK_1
|
||||
JP END_1
|
||||
MARK_1
|
||||
LD DE, MARKED
|
||||
CALL PRINTS
|
||||
END_1
|
||||
POP HL
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
O2
|
||||
LD DE, DIE2
|
||||
CALL PRINTS
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, MARK_2
|
||||
JP END_2
|
||||
MARK_2
|
||||
LD DE, MARKED
|
||||
CALL PRINTS
|
||||
END_2
|
||||
DEC L
|
||||
POP HL
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
O3
|
||||
LD DE, DIE3
|
||||
CALL PRINTS
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, MARK_3
|
||||
JP END_3
|
||||
MARK_3
|
||||
LD DE, MARKED
|
||||
CALL PRINTS
|
||||
END_3
|
||||
DEC L
|
||||
DEC L
|
||||
POP HL
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
O4
|
||||
LD DE, DIE4
|
||||
CALL PRINTS
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, MARK_4
|
||||
JP END_4
|
||||
MARK_4
|
||||
LD DE, MARKED
|
||||
CALL PRINTS
|
||||
END_4
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
POP HL
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
O5
|
||||
LD DE, DIE5
|
||||
CALL PRINTS
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, MARK_5
|
||||
JP END_5
|
||||
MARK_5
|
||||
LD DE, MARKED
|
||||
CALL PRINTS
|
||||
END_5
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
POP HL
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
O6
|
||||
LD DE, DIE6
|
||||
CALL PRINTS
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CALL PRINTFACE
|
||||
PUSH HL
|
||||
LD HL, HELD_DICE
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
INC L
|
||||
LD A, (HL)
|
||||
CP 1
|
||||
JP Z, MARK_6
|
||||
JP END_6
|
||||
MARK_6
|
||||
LD DE, MARKED
|
||||
CALL PRINTS
|
||||
END_6
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
POP HL
|
||||
LD DE, NEWLINE
|
||||
CALL PRINTS
|
||||
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
DEC L
|
||||
RET
|
||||
|
||||
; Read 1 character when one is ready
|
||||
; A is 00H if none are available
|
||||
INPUTC
|
||||
PUSH HL
|
||||
PUSH BC
|
||||
PUSH DE
|
||||
LD C, CONST
|
||||
CALL BDOS
|
||||
CP 00H
|
||||
JP Z, INPUTCEND
|
||||
; LD C, CONST
|
||||
; CALL BDOS
|
||||
; CP FFH
|
||||
; JR Z, INPUTCEND
|
||||
; LD C, CONIN
|
||||
; CALL BDOS
|
||||
LD C, CONIN
|
||||
CALL BDOS
|
||||
POP DE
|
||||
POP BC
|
||||
POP HL
|
||||
RET
|
||||
INPUTCEND
|
||||
POP DE
|
||||
POP BC
|
||||
POP HL
|
||||
; LD A, 00H
|
||||
; POP BC
|
||||
; POP HL
|
||||
RET
|
||||
|
||||
; Print a string
|
||||
PRINTS
|
||||
; preserve BC register.
|
||||
; preserve HL register.
|
||||
PUSH HL
|
||||
PUSH BC
|
||||
LD C, WRITESTR
|
||||
CALL BDOS
|
||||
POP BC
|
||||
POP HL
|
||||
RET
|
||||
|
||||
PRINTFACE
|
||||
CP 1
|
||||
JP NZ, CHECKTWO
|
||||
LD DE, ONE
|
||||
CALL PRINTS
|
||||
JP PRINTFACE_END
|
||||
|
||||
CHECKTWO
|
||||
CP 2
|
||||
JP NZ, CHECKTHREE
|
||||
LD DE, TWO
|
||||
CALL PRINTS
|
||||
JP PRINTFACE_END
|
||||
|
||||
CHECKTHREE
|
||||
CP 3
|
||||
JP NZ, CHECKFOUR
|
||||
LD DE, THREE
|
||||
CALL PRINTS
|
||||
JP PRINTFACE_END
|
||||
|
||||
CHECKFOUR
|
||||
CP 4
|
||||
JP NZ, CHECKFIVE
|
||||
LD DE, FOUR
|
||||
CALL PRINTS
|
||||
JP PRINTFACE_END
|
||||
|
||||
CHECKFIVE
|
||||
CP 5
|
||||
JP NZ, CHECKSIX
|
||||
LD DE, FIVE
|
||||
CALL PRINTS
|
||||
JP PRINTFACE_END
|
||||
|
||||
CHECKSIX
|
||||
CP 6
|
||||
JP NZ, CHECKBADVALUE
|
||||
LD DE, SIX
|
||||
CALL PRINTS
|
||||
JP PRINTFACE_END
|
||||
|
||||
CHECKBADVALUE
|
||||
LD DE, BADVALUE
|
||||
CALL PRINTS
|
||||
|
||||
PRINTFACE_END
|
||||
RET
|
||||
|
||||
EOS DB "$"
|
||||
WELCOME DB "WELCOME TO DIX MILLE FOR CP/M!$"
|
||||
STOPROLL DB "PRESS ANY KEY AT ANY TIME TO STOP ROLLING A DIE!$"
|
||||
DYWTH DB "DO YOU WANT TO HOLD (Y/N) $"
|
||||
OPTIMAL DB "NOW, DETERMINING OPTIMAL SCORE: $"
|
||||
YOUROLLED DB "RESULTS:$"
|
||||
NEWLINE DB CR, LF, "$"
|
||||
DIE1 DB "DIE 1: $"
|
||||
DIE2 DB "DIE 2: $"
|
||||
DIE3 DB "DIE 3: $"
|
||||
DIE4 DB "DIE 4: $"
|
||||
DIE5 DB "DIE 5: $"
|
||||
DIE6 DB "DIE 6: $"
|
||||
ONE DB "ONE$"
|
||||
TWO DB "TWO$"
|
||||
THREE DB "THREE$"
|
||||
FOUR DB "FOUR$"
|
||||
FIVE DB "FIVE$"
|
||||
SIX DB "SIX$"
|
||||
MARKED DB " *$"
|
||||
CLS DB 1bh, '[2J$' ; ANSI clear screen: ESC [ 2 J
|
||||
HOME DB 1bh, '[H$' ; ANSI go to screen home: ESC [ H
|
||||
BADVALUE DB "BAD VALUE$"
|
||||
|
||||
TOTALHELD DB 0
|
||||
DICE DB 0, 0, 0, 0, 0, 0
|
||||
HELD_DICE DB 0, 0, 0, 0, 0, 0
|
||||
CR equ 0DH
|
||||
LF equ 0AH
|
||||
STACK equ 2000H
|
||||
|
||||
CONST EQU 0BH
|
||||
CONIN EQU 01H
|
||||
BDOS EQU 05H
|
||||
PRTCHR EQU 02H
|
||||
WRITESTR EQU 09H
|
||||
|
||||
END
|
80
src/altair8800/cpm/blinkenlights.asm
Normal file
80
src/altair8800/cpm/blinkenlights.asm
Normal file
@ -0,0 +1,80 @@
|
||||
; blinkenlights.asm
|
||||
; Copyright (C) 2023 William R. Moore
|
||||
;
|
||||
; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
; Modified from https://github.com/kloyd/Retro8080/blob/main/funstuff/blinken_pattern.asm
|
||||
; to run in CP/M and with my own pattern.
|
||||
|
||||
ORG 100H
|
||||
INIT LXI H,DATA ; HL points to blinken data
|
||||
SHLD SAVE_HL
|
||||
|
||||
GETD LHLD SAVE_HL ; restore HL
|
||||
MOV A,M ; get data @ HL
|
||||
CPI EOF ; End of the data list?
|
||||
JZ INIT ; Yes, reset HL pointer.
|
||||
MOV D,A ; No, put in D register for the display pattern.
|
||||
INR L ; HL++
|
||||
SHLD SAVE_HL ; Save data
|
||||
|
||||
INPDEL LXI H,0 ; Init HL to zero before starting the delay loop
|
||||
IN 0FFH
|
||||
CPI 00H ; All Sense switches off finishes the program.
|
||||
JZ DONE
|
||||
LXI B,4H ; Hardcoded timer
|
||||
|
||||
BLINK LDAX D
|
||||
LDAX D
|
||||
LDAX D
|
||||
LDAX D
|
||||
DAD B
|
||||
JNC BLINK
|
||||
JMP GETD
|
||||
; Done with this loop go get the next D
|
||||
|
||||
; Return to CP/M if 00 on sense switches. Some way to drop out.
|
||||
DONE JMP 0H
|
||||
; Somewhere to save HL, since it will get clobbered by the delay routine.
|
||||
SAVE_HL DW 0
|
||||
; Put your pattern list here... this is just jiggy wiggy back forth here.
|
||||
|
||||
DATA
|
||||
DB 10111010b
|
||||
DB 11000011b
|
||||
DB 11011111b
|
||||
DB 10001000b
|
||||
DB 01001000b
|
||||
DB 00110000b
|
||||
DB 01000110b
|
||||
DB 10000010b
|
||||
DB 01101010b
|
||||
DB 01000000b
|
||||
DB 00100111b
|
||||
DB 01010111b
|
||||
DB 00100000b
|
||||
DB 11110010b
|
||||
DB 01101111b
|
||||
DB 10000011b
|
||||
DB 00110011b
|
||||
DB 00010101b
|
||||
DB 10001100b
|
||||
DB 10111011b
|
||||
DB 00000000b
|
||||
|
||||
DB EOF
|
||||
|
||||
|
||||
EOF EQU 042 ; end of data
|
||||
END
|
Loading…
Reference in New Issue
Block a user