Initial commit.

This commit is contained in:
Lee Fastenau 2017-03-12 16:30:49 -07:00
commit daddce6037
11 changed files with 1655 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build

20
conway.sublime-project Normal file
View File

@ -0,0 +1,20 @@
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"tab_size": 8
},
"build_systems":
[
{
"name": "Run",
"working_dir": "${project_path:${folder}}",
"shell_cmd": "make run"
}
]
}

399
conway.sublime-workspace Normal file
View File

@ -0,0 +1,399 @@
{
"auto_complete":
{
"selected_items":
[
]
},
"buffers":
[
{
"file": "makefile",
"settings":
{
"buffer_size": 448,
"encoding": "UTF-8",
"line_ending": "Unix"
}
},
{
"file": "src/conway.asm",
"settings":
{
"buffer_size": 103,
"encoding": "UTF-8",
"line_ending": "Unix"
}
},
{
"file": "conway.sublime-project",
"settings":
{
"buffer_size": 159,
"encoding": "UTF-8",
"line_ending": "Unix"
}
},
{
"file": "include/include.asm",
"settings":
{
"buffer_size": 6,
"encoding": "UTF-8",
"line_ending": "Unix"
}
}
],
"build_system": "Run",
"build_system_choices":
[
[
[
[
"List",
""
],
[
"Packages/Makefile/Make.sublime-build",
""
],
[
"Packages/Makefile/Make.sublime-build",
"Clean"
]
],
[
"List",
""
]
],
[
[
[
"Packages/Makefile/Make.sublime-build",
""
],
[
"Packages/Makefile/Make.sublime-build",
"Clean"
]
],
[
"Packages/Makefile/Make.sublime-build",
""
]
],
[
[
[
"Run",
""
],
[
"Packages/Makefile/Make.sublime-build",
""
],
[
"Packages/Makefile/Make.sublime-build",
"Clean"
]
],
[
"Run",
""
]
]
],
"build_varint": "",
"command_palette":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"console":
{
"height": 0.0,
"history":
[
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"expanded_folders":
[
"/Users/thelbane/code/apple2/conway",
"/Users/thelbane/code/apple2/conway/include",
"/Users/thelbane/code/apple2/conway/src"
],
"file_history":
[
"/Users/thelbane/code/apple2/conway/conway.sublime-project",
"/Users/thelbane/Library/Application Support/Sublime Text 3/Packages/User/Make.sublime-build",
"/Users/thelbane/code/apple2/conway/build/conway",
"/Users/thelbane/code/apple2/conway/conway.asm",
"/Users/thelbane/code/makefile/foo.txt",
"/Users/thelbane/code/makefile/test.txt",
"/Users/thelbane/code/web/node-postgres-todo/model/database.js",
"/Users/thelbane/code/web/nodetest/test.txt",
"/Users/thelbane/code/web/nodetest/node_modules/express/lib/application.js",
"/Users/thelbane/code/web/nodetest/app/calc.js",
"/Users/thelbane/code/web/nodetest/file.md",
"/Users/thelbane/code/web/nodetest/app/index.js",
"/Users/thelbane/code/web/nodetest/index.js",
"/Users/thelbane/code/web/nodetest/package.json",
"/Users/thelbane/.zshrc",
"/Users/thelbane/.plan"
],
"find":
{
"height": 23.0
},
"find_in_files":
{
"height": 93.0,
"where_history":
[
""
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"app",
"app.js",
"{\n"
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
],
"reverse": false,
"show_context": true,
"use_buffer2": true,
"whole_word": false,
"wrap": true
},
"groups":
[
{
"selected": 2,
"sheets":
[
{
"buffer": 0,
"file": "makefile",
"semi_transient": false,
"settings":
{
"buffer_size": 448,
"regions":
{
},
"selection":
[
[
432,
432
]
],
"settings":
{
"syntax": "Packages/Makefile/Makefile.sublime-syntax"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 2,
"type": "text"
},
{
"buffer": 1,
"file": "src/conway.asm",
"semi_transient": false,
"settings":
{
"buffer_size": 103,
"regions":
{
},
"selection":
[
[
0,
0
]
],
"settings":
{
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
},
{
"buffer": 2,
"file": "conway.sublime-project",
"semi_transient": false,
"settings":
{
"buffer_size": 159,
"regions":
{
},
"selection":
[
[
159,
159
]
],
"settings":
{
"syntax": "Packages/JavaScript/JSON.sublime-syntax"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 3,
"file": "include/include.asm",
"semi_transient": false,
"settings":
{
"buffer_size": 6,
"regions":
{
},
"selection":
[
[
6,
6
]
],
"settings":
{
"syntax": "Packages/Text/Plain text.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 3,
"type": "text"
}
]
}
],
"incremental_find":
{
"height": 23.0
},
"input":
{
"height": 31.0
},
"layout":
{
"cells":
[
[
0,
0,
1,
1
]
],
"cols":
[
0.0,
1.0
],
"rows":
[
0.0,
1.0
]
},
"menu_visible": true,
"output.exec":
{
"height": 461.0
},
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"project": "conway.sublime-project",
"replace":
{
"height": 42.0
},
"save_all_on_build": true,
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_project":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_symbol":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"selected_group": 0,
"settings":
{
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 150.0,
"status_bar_visible": true,
"template_settings":
{
}
}

36
include/apple2.asm Normal file
View File

@ -0,0 +1,36 @@
; ------------------------------------
; Zero Page Constants
; ------------------------------------
; Free zero page locacations according to
; http://home.swbell.net/rubywand/csa2pfaq.html#017
ZPA0 equ $06
ZPA1 equ $07
ZPA2 equ $08
ZPA3 equ $09
HTAB equ $24
VTAB equ $25
TXTROW equ $28
ZPB0 equ $EB
ZPB1 equ $EC
ZPB2 equ $ED
ZPB3 equ $EE
ZPB4 equ $EF
ZPC0 equ $FA
ZPC1 equ $FB
ZPC2 equ $FC
ZPC3 equ $FD
STACK equ $100
TXTPG0 equ $0400
TXTPG1 equ $0800
CLICK equ $C030
HOME equ $FC58
PUTCHAR equ $FDED
EXITDOS equ $03D0

31
include/macros.asm Normal file
View File

@ -0,0 +1,31 @@
mac LOG_REGION
if {3} && >. != >{2}
echo "(",{2},"-",.,")",{1},"*** BOUNDARY CROSSED ***"
err
else
echo "(",{2},"-",.,")",{1}
endif
endm
mac WARN_BOUNDARY
.start set {2}
.end set *
if >.start != >.end
echo "Page boundary crossed (",{1},.start,"-",.end,")"
endif
endm
mac REQUIRED_BOUNDARY
.start set {2}
.end set *
if >.start == >.end
echo "Expected page boundary not crossed (",{1},.start,"-",.end,")"
endif
endm
mac ABORT
echo ""
echo "*** ABORTING ASSEMBLY"
echo "***", {0}
err
endm

69
include/utilities.asm Normal file
View File

@ -0,0 +1,69 @@
printline subroutine
tsx
inx
lda STACK,x
sta ZPA0
lda STACK+1,x
sta ZPA1
.loop
inc ZPA0
bne .cont
inc ZPA1
.cont
ldy #0
lda (ZPA0),y
beq .cleanup
ora #%10000000
jsr PUTCHAR
bne .loop
.cleanup
lda ZPA0
sta STACK,x
.end
lda ZPA1
sta STACK+1,x
rts
rand subroutine
jsr rand64k ;Factors of 65535: 3 5 17 257
jsr rand32k ;Factors of 32767: 7 31 151 are independent and can be combined
lda sr1+1 ;can be left out
eor sr2+1 ;if you dont use
tay ;y as suggested
lda sr1 ;mix up lowbytes of SR1
eor sr2 ;and SR2 to combine both
rts
;periode with 65535
;10+12+13+15
rand64k subroutine
lda sr1+1
asl
asl
eor sr1+1
asl
eor sr1+1
asl
asl
eor sr1+1
asl
rol sr1 ;shift this left, "random" bit comes from low
rol sr1+1
rts
;periode with 32767
;13+14
rand32k subroutine
lda sr2+1
asl
eor sr2+1
asl
asl
ror sr2 ;shift this right, random bit comes from high - nicer when eor with sr1
rol sr2+1
rts
;feel free to set seeds as wished, if put in zeropage some speed-boost is
;the result. For example sr1=$5c sr2=5e would fit
sr1 dc.w $a55a
sr2 dc.w $7653

45
makefile Normal file
View File

@ -0,0 +1,45 @@
TARGET = conway
export FILENAME = $(shell echo $(TARGET) | tr a-z A-Z)
TYPE = B
AC = java -jar /usr/local/bin/ac.jar
SDIR = ./src
_SRC = $(TARGET).asm
SRC = $(patsubst %,$(SDIR)/%,$(_SRC))
IDIR = ./include
_DEPS = apple2.asm macros.asm utilities.asm
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
BDIR = ./build
_OBJ = $(TARGET)
OBJ = $(patsubst %,$(BDIR)/%,$(_OBJ))
_LST = $(TARGET).lst
LST = $(patsubst %,$(BDIR)/%,$(_LST))
_IMAGE = $(TARGET).dsk
export IMAGE = $(patsubst %,$(BDIR)/%,$(_IMAGE))
RDIR = ./res
_BOOTIMAGE = dos3.3bootable.dsk
BOOTIMAGE = $(patsubst %,$(RDIR)/%,$(_BOOTIMAGE))
_RUNNER = runner.scpt
RUNNER = $(patsubst %,$(RDIR)/%,$(_RUNNER))
all: $(OBJ)
$(OBJ): $(SRC) $(DEPS)
@mkdir -p $(BDIR)
dasm $< -o$@ -l$(LST) -v4 -f2
$(IMAGE): $(OBJ)
cp $(BOOTIMAGE) $(IMAGE)
$(AC) -cc65 $(IMAGE) $(TARGET) $(TYPE) < $(OBJ)
run: $(IMAGE)
osascript $(RUNNER)
@echo Running...
clean:
@rm -rf $(BDIR)
@echo Cleaned!

BIN
res/dos3.3bootable.dsk Normal file

Binary file not shown.

BIN
res/runner.scpt Normal file

Binary file not shown.

1054
src/conway.asm Normal file

File diff suppressed because it is too large Load Diff