1
0
mirror of https://github.com/irmen/ksim65.git synced 2024-06-06 07:29:29 +00:00

Compare commits

...

45 Commits
v1.7 ... master

Author SHA1 Message Date
Irmen de Jong
3f28ef6cad update gradle 2023-10-30 20:24:14 +01:00
Irmen de Jong
0fda62370e updates 2023-08-30 13:59:16 +02:00
Irmen de Jong
6812ab4b09 updates 2023-08-15 13:30:01 +02:00
Irmen de Jong
67c70abb41 build fixes 2023-05-26 20:14:55 +02:00
Irmen de Jong
5cc3f8fddd kotlin 1.7.10 2022-08-13 21:24:12 +02:00
Irmen de Jong
87c7aad49a update gradle wrapper to 7.4 2022-03-12 23:22:46 +01:00
Irmen de Jong
1ca771840b kotlin 1.6.10 2022-01-09 03:53:50 +01:00
Irmen de Jong
b17b72b6b5 remote broken dokka build target, upgrade to kotlin 1.5.30 2021-09-19 18:27:25 +02:00
Irmen de Jong
61bb920776 ide files 2021-09-19 18:12:35 +02:00
Irmen de Jong
6c73852b5e update kotlin version 2021-07-06 23:37:19 +02:00
Irmen de Jong
6dc433417d updated to Kotlin 1.4.20 and JDK 11 2020-12-19 14:58:48 +01:00
Irmen de Jong
f8b3213b41 update travix 2020-10-23 00:07:26 +02:00
Irmen de Jong
b2b4b0ab83 gradle upgrade 2020-10-22 23:53:59 +02:00
Irmen de Jong
1cbb006577 updated to new kotlin version 2020-10-13 00:06:28 +02:00
Irmen de Jong
b8691db38e version 1.9 2020-07-07 18:50:02 +02:00
Irmen de Jong
d1d433c3a6 replaced fixed 8x16 bitmap font by psf font 2020-03-17 00:01:45 +01:00
Irmen de Jong
3925c80258 another link to illegal instructions 2020-03-16 21:59:38 +01:00
Irmen de Jong
c2d6954327 added default vice rom path to search list 2020-03-13 17:16:41 +01:00
Irmen de Jong
0670a85f88 upgrade kotlin sdk version, optimized hex number output 2020-03-07 01:17:48 +01:00
Irmen de Jong
7522d3cb3b added joystick to C64 emulation (via numpad keys) 2020-03-01 18:38:00 +01:00
Irmen de Jong
99942748f9 when 2020-02-27 03:57:32 +01:00
Irmen de Jong
323098f645 doc 2020-02-21 20:11:17 +01:00
Irmen de Jong
d9f1a76c47 doc 2020-02-21 02:21:55 +01:00
Irmen de Jong
95733df9af exclude c64 specific tests because of roms requirement 2020-02-21 02:15:10 +01:00
Irmen de Jong
ec9b80433f doc 2020-02-21 01:57:00 +01:00
Irmen de Jong
cd00191dcf ver 1.8 2020-02-21 01:46:34 +01:00
Irmen de Jong
31962d083f more fun c64 demos 2020-02-21 01:28:50 +01:00
Irmen de Jong
1e27e5bae4 corrected BRK flag incompatibility + unit tests 2020-02-21 01:12:38 +01:00
Irmen de Jong
5667c00d85 fixed cycle times, implemented various illegal opcodes. NesTest now runs flawlessly 2020-02-20 03:32:06 +01:00
Irmen de Jong
35cbe4e3ca tweak 6510 io port and fix overflow bug in TOD 2020-02-20 00:01:54 +01:00
Irmen de Jong
99d8f5cd97 fix 'a' command 2020-02-19 01:13:18 +01:00
Irmen de Jong
be8716c4a4 use assembler instead of raw bytes 2020-02-19 00:48:05 +01:00
Irmen de Jong
deaf79fcc2 introduced separate Assembler class 2020-02-19 00:29:07 +01:00
Irmen de Jong
c619ddabf1 introduced separate Disassembler class 2020-02-18 22:01:12 +01:00
Irmen de Jong
d5f533c300 fix power on values of cpu port registers 2020-02-18 19:51:05 +01:00
Irmen de Jong
62e2f1663a test tweak 2020-02-18 04:48:56 +01:00
Irmen de Jong
57e9bacef9 fix vic bank screen address miscalculation 2020-02-18 04:21:35 +01:00
Irmen de Jong
2ad73432f6 do not crash anymore when multicolor mode is enabled 2020-02-18 02:54:04 +01:00
Irmen de Jong
1123ddf482 trying to add the nestest rom 2020-02-18 02:08:07 +01:00
Irmen de Jong
08880c5d77 added the 'bbc beeb' bcd tests 2020-02-18 01:25:01 +01:00
Irmen de Jong
3888b142d2 split up the test suite some more 2020-02-17 23:45:20 +01:00
Irmen de Jong
a8874fd05a notes 2020-02-17 02:17:34 +01:00
Irmen de Jong
5d9c54eaf6 jcenter 2020-02-17 00:06:14 +01:00
Irmen de Jong
ffbd5050d6 jcenter 2020-02-16 23:54:52 +01:00
Irmen de Jong
0dd97ba41c todo sprite collisions 2020-02-16 23:04:51 +01:00
314 changed files with 107966 additions and 1465 deletions

6
.idea/compiler.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

View File

@ -15,8 +15,6 @@
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="useAutoImport" value="true" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@ -26,5 +26,10 @@
<option name="name" value="maven" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
</component>
</project>

6
.idea/kotlinc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.9.10" />
</component>
</project>

View File

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="openjdk-11" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="openjdk-11" project-jdk-type="JavaSDK" />
</project>

View File

@ -1,10 +0,0 @@
language: java
sudo: false
# jdk: openjdk8
# dist: xenial
before_install:
- chmod +x gradlew
script:
- gradle test

View File

@ -1,13 +1,7 @@
[![saythanks](https://img.shields.io/badge/say-thanks-ff69b4.svg)](https://saythanks.io/to/irmen)
[![Build Status](https://travis-ci.org/irmen/ksim65.svg?branch=master)](https://travis-ci.org/irmen/ksim65)
# KSim65 - Kotlin/JVM 6502/65C02 microprocessor simulator
*Written by Irmen de Jong (irmen@razorvine.net)*
*Software license: MIT, see file LICENSE*
![6502](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/KL_MOS_6502.jpg/320px-KL_MOS_6502.jpg)
This is a Kotlin/JVM library that simulates the 8-bit 6502 and 65C02 microprocessors,
@ -15,21 +9,41 @@ This is a Kotlin/JVM library that simulates the 8-bit 6502 and 65C02 microproces
Properties of this simulator:
- Written in Kotlin. It is low-level code, but hopefully still readable :-)
- Designed to simulate various hardware components (bus, cpu, memory, i/o controllers)
- IRQ and NMI simulation
- Aims to simulate correct instruction cycle timing, but is not 100% cycle exact for simplicity
- Aims to implements all 6502 and 65c02 instructions, including the 'illegal' 6502 instructions (not yet done)
- written in Kotlin. It is low-level code, but hopefully still readable :-)
- simulates various hardware components (bus, cpu, memory, i/o controllers)
- IRQ and NMI
- instruction cycle times are simulated (however the *internal* cpu behavior is not cycle-exact for simplicity reasons)
- has all 6502 and 65c02 instructions, including many of the 'illegal' 6502 instructions (goal is 100% eventually)
- correct BCD mode for adc/sbc instructions on both cpu types
- passes several extensive unit test suites that verify instruction and cpu flags behavior
- simple debugging machine monitor, which basic disassembler and assembler functions
- provide a few virtual example machines, one of which is a Commodore-64
- provide a few virtual example machines, one of which is a fairly capable Commodore-64
## Documentation
Still to be written. For now, use the source ;-)
## Using it as a library in your own project
**TODO move to another repository for published packages.**
You can simply add it as a dependency to your project.
For Maven:
<dependency>
<groupId>net.razorvine</groupId>
<artifactId>ksim65</artifactId>
<version>1.10</version>
<type>pom</type>
</dependency>
For Gradle:
implementation 'net.razorvine:ksim65:1.10'
Update the version as required.
## Virtual machine examples
@ -46,3 +60,36 @@ various timers and IRQs. It's not cycle perfect, and the video display is drawn
so raster splits/rasterbars are impossible. But many other things work fine.
![C64 emulation](c64.png)
### License information
Ksim65 itself is licensed under the MIT software license, see file LICENSE.
It includes the 'Spleen' bitmap font (https://github.com/fcambus/spleen),
which has the following license (BSD):
Copyright (c) 2018-2020, Frederic Cambus
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,4 +1,3 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*
import kotlin.math.max
@ -6,32 +5,39 @@ import kotlin.math.max
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
kotlin("jvm") version "1.3.61"
kotlin("jvm") version "1.9.10"
`maven-publish`
application
id("org.jetbrains.dokka") version "0.10.0"
id("com.jfrog.bintray") version "1.8.4"
java
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
allprojects {
val versionProps = Properties().also {
it.load(File("$projectDir/src/main/resources/version.properties").inputStream())
}
version = versionProps["version"] as String
group = "net.razorvine"
base.archivesBaseName = "ksim65"
// base.archivesBaseName = "ksim65"
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenLocal()
jcenter()
mavenCentral()
maven("https://jitpack.io")
}
}
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-reflect")
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
@ -40,11 +46,11 @@ dependencies {
// Use the Kotlin JUnit5 integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
subprojects.forEach {
archives(it)
implementation(it)
}
}
@ -61,35 +67,27 @@ tasks {
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
named<DokkaTask>("dokka") {
outputFormat = "html"
outputDirectory = "$buildDir/kdoc"
configuration {
skipEmptyPackages = true
}
kotlinOptions.jvmTarget = "11"
}
}
val c64emuScript by tasks.registering(CreateStartScripts::class) {
outputDir = File(project.buildDir, "bin")
outputDir = project.layout.buildDirectory.dir("bin").get().asFile
applicationName = "c64emu"
mainClassName = "razorvine.c64emu.C64MainKt"
mainClass.set("razorvine.c64emu.C64MainKt")
classpath = project.tasks["jar"].outputs.files+project.configurations.runtimeClasspath.get()
}
val ehbasicScript by tasks.registering(CreateStartScripts::class) {
outputDir = File(project.buildDir, "bin")
outputDir = project.layout.buildDirectory.dir("bin").get().asFile
applicationName = "ehbasic"
mainClassName = "razorvine.examplemachines.EhBasicMainKt"
mainClass.set("razorvine.examplemachines.EhBasicMainKt")
classpath = project.tasks["jar"].outputs.files+project.configurations.runtimeClasspath.get()
}
application {
applicationName = "ksim65vm"
mainClassName = "razorvine.examplemachines.MachineMainKt"
mainClass.set("razorvine.examplemachines.MachineMainKt")
applicationDistribution.into("bin") {
from(c64emuScript, ehbasicScript)
fileMode = 493
@ -102,12 +100,6 @@ val sourcesJar by tasks.registering(Jar::class) {
from(sourceSets.main.get().allSource)
}
val dokkaDocs by tasks.registering(Jar::class) {
dependsOn("dokka")
archiveClassifier.set("kdoc")
from(fileTree(File(project.buildDir, "kdoc")))
}
publishing {
repositories {
mavenLocal()
@ -116,28 +108,6 @@ publishing {
register("mavenJava", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
artifact(dokkaDocs.get())
}
}
}
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
setPublications(* publishing.publications.names.toTypedArray())
// setConfigurations("archives")
pkg = PackageConfig().also {
it.name = "ksim65"
it.repo = "maven"
it.setLicenses("MIT")
it.vcsUrl = "https://github.com/irmen/ksim65.git"
it.setLabels("6502", "retro", "emulation", "c64")
it.githubRepo = it.vcsUrl
it.version = VersionConfig().also {
it.gpg = GpgConfig().also {
it.sign = true
}
}
}
}

BIN
c64testprgs/atlantis.prg Normal file

Binary file not shown.

BIN
c64testprgs/inaloop.prg Normal file

Binary file not shown.

BIN
c64testprgs/joytest.prg Normal file

Binary file not shown.

BIN
free-c64-roms/basic Normal file

Binary file not shown.

BIN
free-c64-roms/chargen Normal file

Binary file not shown.

BIN
free-c64-roms/kernal Normal file

Binary file not shown.

24
free-c64-roms/readme.txt Normal file
View File

@ -0,0 +1,24 @@
Free/open source roms for the C64
See https://github.com/MEGA65/open-roms
The following copyright notices apply to the entirety of this package,
including each source file, unless otherwise noted in each file or directory.
Copyright Paul Gardner-Stephen, 2019.
Copyright Roman Standzikowski (FeralChil64), 2019-2020.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -2,3 +2,4 @@ org.gradle.caching=true
org.gradle.console=rich
org.gradle.parallel=true
org.gradle.daemon=true
kotlin.code.style=official

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

269
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,78 +17,113 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -105,79 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

25
gradlew.bat vendored
View File

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View File

@ -9,12 +9,20 @@ import java.awt.event.KeyEvent
/**
* Minimal simulation of the MOS 6526 CIA chip.
* Depending on what CIA it is (1 or 2), some registers do different things on the C64.
* This implementation provides a working keyboard matrix, TOD clock, and the essentials of the timer A and B.
* This implementation provides a working keyboard matrix, joystick in port#2 (cia 1),
* time of day clock, and the essentials of the timer A and B.
*/
class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu: Cpu6502) : MemMappedComponent(startAddress, endAddress) {
private var ramBuffer = Array<UByte>(endAddress-startAddress+1) { 0 }
private var regPRA = 0xff
// joystick in port 2 configuration (only works on cia#1)
private var joy2up = false
private var joy2down = false
private var joy2left = false
private var joy2right = false
private var joy2fire = false
class TimeOfDay {
private var updatedAt = 0L
private var startedAt = 0L
@ -52,6 +60,8 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
if (updatedAt != latchedTime) {
updatedAt = latchedTime
var elapsedSeconds = (latchedTime.toDouble()-startedAt)/1000.0+userStartTime
if(elapsedSeconds>60*3600)
elapsedSeconds=0.0 // TOD counds max 60 hours
hours = (elapsedSeconds/3600).toInt()
elapsedSeconds -= hours*3600
minutes = (elapsedSeconds/60).toInt()
@ -84,7 +94,7 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
totalCycles++
if (totalCycles%20000 == 0) {
// TOD resolution is 0.1 second, no need to update it in every cycle
// TOD resolution is 0.1 second, no need to update it in every bus cycle
tod.update()
}
@ -123,6 +133,11 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
timerAset = 0
timerBactual = 0
timerBset = 0
joy2up = false
joy2down = false
joy2left = false
joy2right = false
joy2fire = false
}
override operator fun get(offset: Int): UByte {
@ -137,71 +152,85 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
}
val register = offset and 15
if (number == 1 && register == 0x01) {
// register 1 on CIA#1 is the keyboard data port
// if bit is cleared in PRA, contains keys pressed in that column of the matrix
return when (regPRA) {
0b00000000 -> {
// check if any keys are pressed at all (by checking all columns at once)
if (hostKeyPresses.isEmpty()) 0xff.toShort() else 0x00.toShort()
}
0b11111110 -> {
// read column 0
scanColumn(HostKeyPress(KeyEvent.VK_DOWN), HostKeyPress(KeyEvent.VK_F5), HostKeyPress(KeyEvent.VK_F3),
HostKeyPress(KeyEvent.VK_F1), HostKeyPress(KeyEvent.VK_F7), HostKeyPress(KeyEvent.VK_RIGHT),
HostKeyPress(KeyEvent.VK_ENTER), HostKeyPress(KeyEvent.VK_BACK_SPACE))
}
0b11111101 -> {
// read column 1
scanColumn(HostKeyPress(KeyEvent.VK_SHIFT), // left shift
HostKeyPress(KeyEvent.VK_E), HostKeyPress(KeyEvent.VK_S), HostKeyPress(KeyEvent.VK_Z),
HostKeyPress(KeyEvent.VK_4), HostKeyPress(KeyEvent.VK_A), HostKeyPress(KeyEvent.VK_W),
HostKeyPress(KeyEvent.VK_3))
}
0b11111011 -> {
// read column 2
scanColumn(HostKeyPress(KeyEvent.VK_X), HostKeyPress(KeyEvent.VK_T), HostKeyPress(KeyEvent.VK_F),
HostKeyPress(KeyEvent.VK_C), HostKeyPress(KeyEvent.VK_6), HostKeyPress(KeyEvent.VK_D),
HostKeyPress(KeyEvent.VK_R), HostKeyPress(KeyEvent.VK_5))
}
0b11110111 -> {
// read column 3
scanColumn(HostKeyPress(KeyEvent.VK_V), HostKeyPress(KeyEvent.VK_U), HostKeyPress(KeyEvent.VK_H),
HostKeyPress(KeyEvent.VK_B), HostKeyPress(KeyEvent.VK_8), HostKeyPress(KeyEvent.VK_G),
HostKeyPress(KeyEvent.VK_Y), HostKeyPress(KeyEvent.VK_7))
}
0b11101111 -> {
// read column 4
scanColumn(HostKeyPress(KeyEvent.VK_N), HostKeyPress(KeyEvent.VK_O), HostKeyPress(KeyEvent.VK_K),
HostKeyPress(KeyEvent.VK_M), HostKeyPress(KeyEvent.VK_0), HostKeyPress(KeyEvent.VK_J),
HostKeyPress(KeyEvent.VK_I), HostKeyPress(KeyEvent.VK_9))
}
0b11011111 -> {
// read column 5
scanColumn(HostKeyPress(KeyEvent.VK_COMMA), HostKeyPress(KeyEvent.VK_AT), HostKeyPress(KeyEvent.VK_COLON),
HostKeyPress(KeyEvent.VK_PERIOD), HostKeyPress(KeyEvent.VK_MINUS), HostKeyPress(KeyEvent.VK_L),
HostKeyPress(KeyEvent.VK_P), HostKeyPress(KeyEvent.VK_PLUS))
}
0b10111111 -> {
// read column 6
scanColumn(HostKeyPress(KeyEvent.VK_SLASH), HostKeyPress(KeyEvent.VK_CIRCUMFLEX), HostKeyPress(KeyEvent.VK_EQUALS),
HostKeyPress(KeyEvent.VK_SHIFT, rightSide = true), // right shift
HostKeyPress(KeyEvent.VK_HOME), HostKeyPress(KeyEvent.VK_SEMICOLON), HostKeyPress(KeyEvent.VK_ASTERISK),
HostKeyPress(KeyEvent.VK_DEAD_TILDE) // pound sign
)
}
0b01111111 -> {
// read column 7
scanColumn(HostKeyPress(KeyEvent.VK_ESCAPE), HostKeyPress(KeyEvent.VK_Q), HostKeyPress(KeyEvent.VK_ALT),
HostKeyPress(KeyEvent.VK_SPACE), HostKeyPress(KeyEvent.VK_2), HostKeyPress(KeyEvent.VK_CONTROL),
HostKeyPress(KeyEvent.VK_BACK_QUOTE), HostKeyPress(KeyEvent.VK_1))
}
else -> {
// invalid column selection
0xff
if(number==1) {
// first CIA has keyboard matrix
if(register==0x00) {
// reading $dc00 is joystick in port #2
return (0b01100000
or (if(joy2up) 0 else 0b00000001)
or (if(joy2down) 0 else 0b00000010)
or (if(joy2left) 0 else 0b00000100)
or (if(joy2right) 0 else 0b00001000)
or (if(joy2fire) 0 else 0b00010000)).toShort()
} else if(register==0x01) {
// register 1 on CIA#1 is the keyboard data port (and joystick #1...)
// if bit is cleared in PRA, contains keys pressed in that column of the matrix
// NOTE: we do not emulate a joystick in port #1 as this conflicts with the keyboard.
// just use the joystick in port #2 for now...
return when (regPRA) {
0b00000000 -> {
// check if any keys are pressed at all (by checking all columns at once)
if (hostKeyPresses.isEmpty()) 0xff.toShort() else 0x00.toShort()
}
0b11111110 -> {
// read column 0
scanColumn(HostKeyPress(KeyEvent.VK_DOWN), HostKeyPress(KeyEvent.VK_F5), HostKeyPress(KeyEvent.VK_F3),
HostKeyPress(KeyEvent.VK_F1), HostKeyPress(KeyEvent.VK_F7), HostKeyPress(KeyEvent.VK_RIGHT),
HostKeyPress(KeyEvent.VK_ENTER), HostKeyPress(KeyEvent.VK_BACK_SPACE))
}
0b11111101 -> {
// read column 1
scanColumn(HostKeyPress(KeyEvent.VK_SHIFT), // left shift
HostKeyPress(KeyEvent.VK_E), HostKeyPress(KeyEvent.VK_S), HostKeyPress(KeyEvent.VK_Z),
HostKeyPress(KeyEvent.VK_4), HostKeyPress(KeyEvent.VK_A), HostKeyPress(KeyEvent.VK_W),
HostKeyPress(KeyEvent.VK_3))
}
0b11111011 -> {
// read column 2
scanColumn(HostKeyPress(KeyEvent.VK_X), HostKeyPress(KeyEvent.VK_T), HostKeyPress(KeyEvent.VK_F),
HostKeyPress(KeyEvent.VK_C), HostKeyPress(KeyEvent.VK_6), HostKeyPress(KeyEvent.VK_D),
HostKeyPress(KeyEvent.VK_R), HostKeyPress(KeyEvent.VK_5))
}
0b11110111 -> {
// read column 3
scanColumn(HostKeyPress(KeyEvent.VK_V), HostKeyPress(KeyEvent.VK_U), HostKeyPress(KeyEvent.VK_H),
HostKeyPress(KeyEvent.VK_B), HostKeyPress(KeyEvent.VK_8), HostKeyPress(KeyEvent.VK_G),
HostKeyPress(KeyEvent.VK_Y), HostKeyPress(KeyEvent.VK_7))
}
0b11101111 -> {
// read column 4
scanColumn(HostKeyPress(KeyEvent.VK_N), HostKeyPress(KeyEvent.VK_O), HostKeyPress(KeyEvent.VK_K),
HostKeyPress(KeyEvent.VK_M), HostKeyPress(KeyEvent.VK_0), HostKeyPress(KeyEvent.VK_J),
HostKeyPress(KeyEvent.VK_I), HostKeyPress(KeyEvent.VK_9))
}
0b11011111 -> {
// read column 5
scanColumn(HostKeyPress(KeyEvent.VK_COMMA), HostKeyPress(KeyEvent.VK_AT), HostKeyPress(KeyEvent.VK_COLON),
HostKeyPress(KeyEvent.VK_PERIOD), HostKeyPress(KeyEvent.VK_MINUS), HostKeyPress(KeyEvent.VK_L),
HostKeyPress(KeyEvent.VK_P), HostKeyPress(KeyEvent.VK_PLUS))
}
0b10111111 -> {
// read column 6
scanColumn(HostKeyPress(KeyEvent.VK_SLASH), HostKeyPress(KeyEvent.VK_CIRCUMFLEX), HostKeyPress(KeyEvent.VK_EQUALS),
HostKeyPress(KeyEvent.VK_SHIFT, rightSide = true), // right shift
HostKeyPress(KeyEvent.VK_HOME), HostKeyPress(KeyEvent.VK_SEMICOLON), HostKeyPress(KeyEvent.VK_ASTERISK),
HostKeyPress(KeyEvent.VK_DEAD_TILDE) // pound sign
)
}
0b01111111 -> {
// read column 7
scanColumn(HostKeyPress(KeyEvent.VK_ESCAPE), HostKeyPress(KeyEvent.VK_Q), HostKeyPress(KeyEvent.VK_ALT),
HostKeyPress(KeyEvent.VK_SPACE), HostKeyPress(KeyEvent.VK_2), HostKeyPress(KeyEvent.VK_CONTROL),
HostKeyPress(KeyEvent.VK_BACK_QUOTE), HostKeyPress(KeyEvent.VK_1))
}
else -> {
// invalid column selection
0xff
}
}
}
} else ramBuffer[register]
}
return when (register) {
0x04 -> (timerAactual and 0xff).toShort()
@ -222,19 +251,6 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
}
}
private fun toBCD(data: Int): UByte {
val tens = data/10
val ones = data-tens*10
return ((tens shl 4) or ones).toShort()
}
private fun fromBCD(bcd: UByte): Int {
val ibcd = bcd.toInt()
val tens = ibcd ushr 4
val ones = ibcd and 0x0f
return tens*10+ones
}
override operator fun set(offset: Int, data: UByte) {
val register = offset and 15
if (number == 1 && register == 0x00) {
@ -294,6 +310,19 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
}
}
private fun toBCD(data: Int): UByte {
val tens = data/10
val ones = data-tens*10
return ((tens shl 4) or ones).toShort()
}
private fun fromBCD(bcd: UByte): Int {
val ibcd = bcd.toInt()
val tens = ibcd ushr 4
val ones = ibcd and 0x0f
return tens*10+ones
}
fun hostKeyPressed(event: KeyEvent) {
val rightSide = event.keyLocation == KeyEvent.KEY_LOCATION_RIGHT
val numpad = event.keyLocation == KeyEvent.KEY_LOCATION_NUMPAD
@ -372,4 +401,15 @@ class Cia(val number: Int, startAddress: Address, endAddress: Address, val cpu:
}
}
}
fun setJoystick2(up: Boolean, down: Boolean, left: Boolean, right: Boolean, fire: Boolean) {
if(number!=1)
throw NotImplementedError("joystick port 2 is connected to cia#1")
joy2up = up
joy2down = down
joy2left = left
joy2right = right
joy2fire = fire
}
}

View File

@ -1,18 +1,18 @@
package razorvine.c64emu
import razorvine.ksim65.Cpu6502
import razorvine.ksim65.components.MemMappedComponent
import razorvine.ksim65.components.UByte
/**
* The 6510's IO port located at $00/$01
* Controlling the memory layout, and cassette port (not processed at all).
*
* TODO: there are a few functional tests that still fail. Is this not implemented correctly yet?
*/
class CpuIoPort(val cpu: Cpu6502) : MemMappedComponent(0x0000, 0x0001) {
class CpuIoPort : MemMappedComponent(0x0000, 0x0001) {
private var dataDirections: Int = 0
private var ioPort: Int = 0xff
private var ioPort: Int = 0
var loram: Boolean = false // Bit 0: LORAM signal. Selects ROM or RAM at 40960 ($A000). 1=BASIC, 0=RAM
private set
var hiram: Boolean = false // Bit 1: HIRAM signal. Selects ROM or RAM at 57344 ($E000). 1=Kernal, 0=RAM
@ -22,14 +22,19 @@ class CpuIoPort(val cpu: Cpu6502) : MemMappedComponent(0x0000, 0x0001) {
override fun clock() { }
override fun reset() {
dataDirections = 0xff
ioPort = 0xff
dataDirections = 0xef
ioPort = 0x37
determineRoms()
}
override operator fun get(offset: Int): UByte {
return if(offset==0) dataDirections.toShort() else {
(ioPort or dataDirections.inv() and 0b00111111).toShort()
return if(offset==0) {
dataDirections.toShort()
} else {
if(dataDirections and 0b00100000 == 0)
(ioPort and 0b11011111).toShort() // bit 5 is low when input
else
ioPort.toShort()
}
}
@ -38,14 +43,14 @@ class CpuIoPort(val cpu: Cpu6502) : MemMappedComponent(0x0000, 0x0001) {
dataDirections = data.toInt()
determineRoms()
} else {
ioPort = data.toInt()
ioPort = (ioPort and dataDirections.inv()) or (data.toInt() and dataDirections)
determineRoms()
}
}
private fun determineRoms() {
if (dataDirections and 0b00000001 != 0) loram = ioPort and 0b00000001 != 0
if (dataDirections and 0b00000010 != 0) hiram = ioPort and 0b00000010 != 0
if (dataDirections and 0b00000100 != 0) charen = ioPort and 0b00000100 != 0
loram = ioPort and 0b00000001 != 0
hiram = ioPort and 0b00000010 != 0
charen = ioPort and 0b00000100 != 0
}
}

View File

@ -82,16 +82,50 @@ class MainC64Window(title: String, chargen: Rom, val ram: MemoryComponent, val c
// keyboard events:
override fun keyTyped(event: KeyEvent) {}
private var joy2up = false
private var joy2down = false
private var joy2left = false
private var joy2right = false
private var joy2fire = false
override fun keyPressed(event: KeyEvent) {
// '\' is mapped as RESTORE, this causes a NMI on the cpu
if (event.keyChar == '\\') {
cpu.nmiAsserted = true
} else {
keypressCia.hostKeyPressed(event)
if(event.keyLocation==KeyEvent.KEY_LOCATION_NUMPAD) {
// numpad is joystick #2
if (event.keyChar in "789") joy2up = true
if (event.keyChar in "123") joy2down = true
if (event.keyChar in "741") joy2left = true
if (event.keyChar in "963") joy2right = true
if (event.keyChar in "05\n") joy2fire = true
keypressCia.setJoystick2(joy2up, joy2down, joy2left, joy2right, joy2fire)
} else {
keypressCia.hostKeyPressed(event)
}
}
}
override fun keyReleased(event: KeyEvent) {
keypressCia.hostKeyPressed(event)
if(event.keyLocation==KeyEvent.KEY_LOCATION_NUMPAD) {
// numpad is joystick #2
if (event.keyChar in "789") joy2up = false
if (event.keyChar in "123") joy2down = false
if (event.keyChar in "741") joy2left = false
if (event.keyChar in "963") joy2right = false
if (event.keyChar in "05\n") joy2fire = false
keypressCia.setJoystick2(joy2up, joy2down, joy2left, joy2right, joy2fire)
} else {
keypressCia.hostKeyPressed(event)
}
}
fun reset() {
joy2up = false
joy2down = false
joy2left = false
joy2right = false
joy2fire = false
}
}

View File

@ -14,6 +14,7 @@ import javax.swing.JPanel
* It supports: Character mode,
* High res bitmap mode (320*200), Multicolor bitmap mode (160*200).
* TODO: Multicolor character mode. Extended background color mode.
* TODO: Horizontal smooth scrolling (+38 col mode). Vertical smooth scrolling (+24 row mode).
*/
internal class Screen(private val chargen: Rom, val ram: MemoryComponent) : JPanel() {
@ -109,7 +110,7 @@ internal class Screen(private val chargen: Rom, val ram: MemoryComponent) : JPan
}
private fun renderSprites(vicBank: Address) {
// TODO sprite-background priorities
// TODO sprite-background priorities, collisions
// TODO multicolor sprites
val spriteImage = fullscreenG2d.deviceConfiguration.createCompatibleImage(24, 21, Transparency.TRANSLUCENT)
val spriteGfx = spriteImage.graphics
@ -147,17 +148,17 @@ internal class Screen(private val chargen: Rom, val ram: MemoryComponent) : JPan
private fun renderCharacterMode(vicBank: Address, vicVMCSB: Int, multiColorMode: Boolean) {
if (multiColorMode) {
TODO("multicolor character mode")
} else {
// normal character mode
val screenAddress = vicBank+(vicVMCSB ushr 4) shl 10
val charsetAddress = (vicVMCSB and 0b00001110) shl 10
for (y in 0 until ScreenDefs.SCREEN_HEIGHT_CHARS) {
for (x in 0 until ScreenDefs.SCREEN_WIDTH_CHARS) {
val char = ram[screenAddress+x+y*ScreenDefs.SCREEN_WIDTH_CHARS].toInt()
val color = ram[0xd800+x+y*ScreenDefs.SCREEN_WIDTH_CHARS].toInt() // colors always at $d800
drawColoredChar(x, y, char, color, vicBank+charsetAddress)
}
// TODO multicolor character mode, for now, falls back to normal char mode
}
// normal character mode
val screenAddress = vicBank+((vicVMCSB ushr 4) shl 10)
val charsetAddress = (vicVMCSB and 0b00001110) shl 10
for (y in 0 until ScreenDefs.SCREEN_HEIGHT_CHARS) {
for (x in 0 until ScreenDefs.SCREEN_WIDTH_CHARS) {
val char = ram[screenAddress+x+y*ScreenDefs.SCREEN_WIDTH_CHARS].toInt()
val color = ram[0xd800+x+y*ScreenDefs.SCREEN_WIDTH_CHARS].toInt() // colors always at $d800
drawColoredChar(x, y, char, color, vicBank+charsetAddress)
}
}
}

View File

@ -39,12 +39,12 @@ class C64Machine(title: String) : IVirtualMachine {
it.load(kernalData)
}
override val cpu = Cpu6502()
val cpuIoPort = CpuIoPort(cpu)
val cpuIoPort = CpuIoPort()
// This bus contains "mmu" logic to control the memory bank switching controlled by the 6510's io port in $00/$01.
// Therefore we provide it the various roms directly and not "connect" these to the bus in the default way.
override val bus = Bus6510(cpuIoPort, chargenRom, basicRom, kernalRom)
override val cpu = Cpu6502()
// the C64 has 64KB of RAM. Some of it may be banked out and replaced by ROM.
val ram = Ram(0x0000, 0xffff)
@ -87,7 +87,7 @@ class C64Machine(title: String) : IVirtualMachine {
val txttab = ram[0x2b]+256*ram[0x2c] // basic load address ($0801 usually)
val fnaddr = ram[0xbb]+256*ram[0xbc] // file name address
return if (fnlen > 0) {
val filename = (0 until fnlen).map { ram[fnaddr+it].toChar() }.joinToString("")
val filename = (0 until fnlen).map { ram[fnaddr+it].toInt().toChar() }.joinToString("")
val loadEndAddress = searchAndLoadFile(filename, fa, sa, txttab)
if (loadEndAddress != null) {
ram[0x90] = 0 // status OK
@ -108,7 +108,7 @@ class C64Machine(title: String) : IVirtualMachine {
val fromAddr = ram[cpu.regA]+256*ram[cpu.regA+1]
val endAddr = cpu.regX+256*cpu.regY
val data = (fromAddr..endAddr).map { ram[it].toByte() }.toByteArray()
var filename = (0 until fnlen).map { ram[fnaddr+it].toChar() }.joinToString("").toLowerCase()
var filename = (0 until fnlen).map { ram[fnaddr+it].toInt().toChar() }.joinToString("").lowercase()
if (!filename.endsWith(".prg")) filename += ".prg"
File(filename).outputStream().use {
it.write(fromAddr and 0xff)
@ -133,13 +133,13 @@ class C64Machine(title: String) : IVirtualMachine {
"$" -> {
// load the directory
val files = File(".").listFiles(FileFilter { it.isFile })!!.associate {
val name = it.nameWithoutExtension.toUpperCase()
val ext = it.extension.toUpperCase()
val name = it.nameWithoutExtension.uppercase()
val ext = it.extension.uppercase()
val fileAndSize = Pair(it, it.length())
if (name.isEmpty()) Pair(".$ext", "") to fileAndSize
else Pair(name, ext) to fileAndSize
}
val dirname = File(".").canonicalPath.substringAfterLast(File.separator).toUpperCase()
val dirname = File(".").canonicalPath.substringAfterLast(File.separator).uppercase()
val dirlisting = makeDirListing(dirname, files, basicLoadAddress)
ram.load(dirlisting, basicLoadAddress)
return basicLoadAddress+dirlisting.size-1
@ -147,7 +147,7 @@ class C64Machine(title: String) : IVirtualMachine {
else -> {
fun findHostFile(filename: String): String? {
val file = File(".").listFiles(FileFilter { it.isFile })?.firstOrNull {
it.name.toUpperCase() == filename
it.name.uppercase() == filename
}
return file?.name
}
@ -179,7 +179,7 @@ class C64Machine(title: String) : IVirtualMachine {
listing.add((address ushr 8).toShort())
listing.add((lineNumber and 0xff).toShort())
listing.add((lineNumber ushr 8).toShort())
listing.addAll(line.map { it.toShort() })
listing.addAll(line.map { it.code.toShort() })
listing.add(0)
}
addLine(0, "\u0012\"${dirname.take(16).padEnd(16)}\" 00 2A")
@ -198,24 +198,6 @@ class C64Machine(title: String) : IVirtualMachine {
return listing.toTypedArray()
}
private fun determineRomPath(): Path {
val candidates = listOf("./roms", "~/roms/c64", "~/roms", "~/.vice/C64")
candidates.forEach {
val path = Paths.get(expandUser(it))
if (path.toFile().isDirectory) return path
}
throw FileNotFoundException("no roms directory found, tried: $candidates")
}
private fun expandUser(path: String): String {
return when {
path.startsWith("~/") -> System.getProperty("user.home")+path.substring(1)
path.startsWith("~"+File.separatorChar) -> System.getProperty("user.home")+path.substring(1)
path.startsWith("~") -> throw UnsupportedOperationException("home dir expansion not implemented for other users")
else -> path
}
}
override fun loadFileInRam(file: File, loadAddress: Address?) {
if (file.extension == "prg" && (loadAddress == null || loadAddress == 0x0801)) ram.loadPrg(file.inputStream(), null)
else ram.load(file.readBytes(), loadAddress!!)
@ -234,6 +216,11 @@ class C64Machine(title: String) : IVirtualMachine {
while (cpu.instrCycles > 0) bus.clock()
}
override fun reset() {
bus.reset()
hostDisplay.reset()
}
override fun executeMonitorCommand(command: String) = monitor.command(command)
fun start() {
@ -268,6 +255,26 @@ class C64Machine(title: String) : IVirtualMachine {
}
}
fun determineRomPath(): Path {
val candidates = listOf("./roms", "~/roms/c64", "~/roms", "~/.vice/C64", "/usr/lib/vice/C64")
candidates.forEach {
val path = Paths.get(expandUser(it))
if (path.toFile().isDirectory) return path
}
throw FileNotFoundException("no roms directory found, tried: $candidates")
}
fun expandUser(path: String): String {
return when {
path.startsWith("~/") -> System.getProperty("user.home")+path.substring(1)
path.startsWith("~"+File.separatorChar) -> System.getProperty("user.home")+path.substring(1)
path.startsWith("~") -> throw UnsupportedOperationException("home dir expansion not implemented for other users")
else -> path
}
}
fun main() {
val machine = C64Machine("virtual Commodore-64 - using KSim65 v${Version.version}")
machine.start()

View File

@ -44,6 +44,7 @@ class DebugWindow(private val vm: IVirtualMachine) : JFrame("Debugger - ksim65 v
it.disabledTextColor = Color.DARK_GRAY
it.font = Font(Font.MONOSPACED, Font.PLAIN, 12)
}
private val disassembler = Disassembler(vm.cpu)
init {
contentPane.layout = GridBagLayout()
@ -181,6 +182,7 @@ class DebugWindow(private val vm: IVirtualMachine) : JFrame("Debugger - ksim65 v
}
"reset" -> {
vm.reset()
vm.bus.reset()
updateCpu(vm.cpu, vm.bus)
}
@ -217,7 +219,8 @@ class DebugWindow(private val vm: IVirtualMachine) : JFrame("Debugger - ksim65 v
regSPtf.text = hexB(state.SP)
val memory = listOf(bus[state.PC], bus[state.PC+1], bus[state.PC+2]).toTypedArray()
val disassem = cpu.disassembleOneInstruction(memory, 0, state.PC).first.substringAfter(' ').trim()
val disassem = disassembler.disassembleOneInstruction(memory, 0, state.PC).first.substringAfter(' ').trim()
disassemTf.text = disassem
if (zeropageTf.isVisible || stackpageTf.isVisible) {

View File

@ -1,57 +1,27 @@
package razorvine.examplemachines
import razorvine.fonts.PsfFont
import razorvine.ksim65.*
import java.awt.*
import java.awt.event.*
import java.awt.image.BufferedImage
import java.util.*
import javax.imageio.ImageIO
import javax.swing.*
import javax.swing.event.MouseInputListener
/**
* Define a monochrome screen that can display 640x480 pixels
* and/or 80x30 characters (these are 8x16 pixels).
* Define a monochrome screen that can display 80x30 charaacters
* (usually equivalent to 640x480 pixels, but depends on the font size)
*/
object ScreenDefs {
const val SCREEN_WIDTH_CHARS = 80
const val SCREEN_HEIGHT_CHARS = 30
const val SCREEN_WIDTH = SCREEN_WIDTH_CHARS*8
const val SCREEN_HEIGHT = SCREEN_HEIGHT_CHARS*16
const val PIXEL_SCALING = 1.5
const val COLUMNS = 80
const val ROWS = 30
const val BORDER_SIZE = 32
val BG_COLOR = Color(0, 10, 20)
val FG_COLOR = Color(200, 255, 230)
val BORDER_COLOR = Color(20, 30, 40)
val Characters = loadCharacters()
private fun loadCharacters(): Array<BufferedImage> {
val img = ImageIO.read(javaClass.getResourceAsStream("/charset/unscii8x16.png"))
val charactersImage = BufferedImage(img.width, img.height, BufferedImage.TYPE_INT_ARGB)
charactersImage.createGraphics().drawImage(img, 0, 0, null)
val black = Color(0, 0, 0).rgb
val foreground = FG_COLOR.rgb
val nopixel = Color(0, 0, 0, 0).rgb
for (y in 0 until charactersImage.height) {
for (x in 0 until charactersImage.width) {
val col = charactersImage.getRGB(x, y)
if (col == black) charactersImage.setRGB(x, y, nopixel)
else charactersImage.setRGB(x, y, foreground)
}
}
val numColumns = charactersImage.width/8
val charImages = (0..255).map {
val charX = it%numColumns
val charY = it/numColumns
charactersImage.getSubimage(charX*8, charY*16, 8, 16)
}
return charImages.toTypedArray()
}
}
private class BitmapScreenPanel : JPanel() {
@ -61,15 +31,21 @@ private class BitmapScreenPanel : JPanel() {
private var cursorX: Int = 0
private var cursorY: Int = 0
private var cursorState: Boolean = false
private val screenFont = PsfFont("spleen-12x24") // nice fonts: sun12x22, iso01-12x22, ter-124b, spleen-12x24, default8x16
private val pixelScaling: Double = if(screenFont.width <= 8) 1.5 else 1.0
private val screenFontImage: BufferedImage
init {
println("SCREENFONT WIDTH: ${screenFont.width}")
val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
val gd = ge.defaultScreenDevice.defaultConfiguration
image = gd.createCompatibleImage(ScreenDefs.SCREEN_WIDTH, ScreenDefs.SCREEN_HEIGHT, Transparency.OPAQUE)
image = gd.createCompatibleImage(ScreenDefs.COLUMNS*screenFont.width, ScreenDefs.ROWS*screenFont.height, Transparency.OPAQUE)
g2d = image.graphics as Graphics2D
screenFontImage = screenFont.convertToImage(g2d, ScreenDefs.FG_COLOR)
val size = Dimension((image.width*ScreenDefs.PIXEL_SCALING).toInt(),
(image.height*ScreenDefs.PIXEL_SCALING).toInt())
val size = Dimension((image.width*pixelScaling).toInt(),
(image.height*pixelScaling).toInt())
minimumSize = size
maximumSize = size
preferredSize = size
@ -82,13 +58,13 @@ private class BitmapScreenPanel : JPanel() {
override fun paint(graphics: Graphics) {
val g2d = graphics as Graphics2D
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
g2d.drawImage(image, 0, 0, (image.width*ScreenDefs.PIXEL_SCALING).toInt(),
(image.height*ScreenDefs.PIXEL_SCALING).toInt(), null)
g2d.drawImage(image, 0, 0, (image.width*pixelScaling).toInt(),
(image.height*pixelScaling).toInt(), null)
if (cursorState) {
val scx = (cursorX*ScreenDefs.PIXEL_SCALING*8).toInt()
val scy = (cursorY*ScreenDefs.PIXEL_SCALING*16).toInt()
val scw = (8*ScreenDefs.PIXEL_SCALING).toInt()
val sch = (16*ScreenDefs.PIXEL_SCALING).toInt()
val scx = (cursorX*pixelScaling*screenFont.width).toInt()
val scy = (cursorY*pixelScaling*screenFont.height).toInt()
val scw = (screenFont.width*pixelScaling).toInt()
val sch = (screenFont.height*pixelScaling).toInt()
g2d.setXORMode(Color.CYAN)
g2d.fillRect(scx, scy, scw, sch)
g2d.setPaintMode()
@ -98,7 +74,7 @@ private class BitmapScreenPanel : JPanel() {
fun clearScreen() {
g2d.background = ScreenDefs.BG_COLOR
g2d.clearRect(0, 0, ScreenDefs.SCREEN_WIDTH, ScreenDefs.SCREEN_HEIGHT)
g2d.clearRect(0, 0, ScreenDefs.COLUMNS*screenFont.width, ScreenDefs.ROWS*screenFont.height)
cursorPos(0, 0)
}
@ -110,20 +86,26 @@ private class BitmapScreenPanel : JPanel() {
fun getPixel(x: Int, y: Int) = image.getRGB(x, y) != ScreenDefs.BG_COLOR.rgb
fun setChar(x: Int, y: Int, character: Char) {
g2d.clearRect(8*x, 16*y, 8, 16)
val coloredImage = ScreenDefs.Characters[character.toInt()]
g2d.drawImage(coloredImage, 8*x, 16*y, null)
val charnum = character.code
val cx = charnum % (screenFontImage.width/screenFont.width)
val cy = charnum / (screenFontImage.width/screenFont.width)
g2d.clearRect(x*screenFont.width, y*screenFont.height, screenFont.width, screenFont.height)
g2d.drawImage(screenFontImage, x*screenFont.width, y*screenFont.height, (x+1)*screenFont.width,
(y+1)*screenFont.height, cx*screenFont.width, cy*screenFont.height,
(cx+1)*screenFont.width, (cy+1)*screenFont.height, null)
}
fun scrollUp() {
g2d.copyArea(0, 16, ScreenDefs.SCREEN_WIDTH, ScreenDefs.SCREEN_HEIGHT-16, 0, -16)
g2d.copyArea(0, screenFont.height,
ScreenDefs.COLUMNS*screenFont.width, (ScreenDefs.ROWS-1)*screenFont.height,
0, -screenFont.height)
g2d.background = ScreenDefs.BG_COLOR
g2d.clearRect(0, ScreenDefs.SCREEN_HEIGHT-16, ScreenDefs.SCREEN_WIDTH, 16)
g2d.clearRect(0, (ScreenDefs.ROWS-1)*screenFont.height, ScreenDefs.COLUMNS*screenFont.width, screenFont.height)
}
fun mousePixelPosition(): Point? {
val pos = mousePosition ?: return null
return Point((pos.x/ScreenDefs.PIXEL_SCALING).toInt(), (pos.y/ScreenDefs.PIXEL_SCALING).toInt())
return Point((pos.x/pixelScaling).toInt(), (pos.y/pixelScaling).toInt())
}
fun cursorPos(x: Int, y: Int) {
@ -242,4 +224,8 @@ class MainWindow(title: String) : JFrame(title), KeyListener, MouseInputListener
else keyboardBuffer.pop()
}
fun reset() {
// when the reset button is pressed
}
}

View File

@ -21,7 +21,7 @@ class EhBasicMachine(title: String) {
val rom = Rom(0xc000, 0xffff).also { it.load(javaClass.getResourceAsStream("/ehbasic_C000.bin").readBytes()) }
private val hostDisplay = MainWindow(title)
private val display = Display(0xd000, 0xd00a, hostDisplay, ScreenDefs.SCREEN_WIDTH_CHARS, ScreenDefs.SCREEN_HEIGHT_CHARS)
private val display = Display(0xd000, 0xd00a, hostDisplay, ScreenDefs.COLUMNS, ScreenDefs.ROWS)
private val keyboard = Keyboard(0xd400, 0xd400, hostDisplay)
private var paused = false

View File

@ -20,7 +20,7 @@ class VirtualMachine(title: String) : IVirtualMachine {
private val monitor = Monitor(bus, cpu)
private val debugWindow = DebugWindow(this)
private val hostDisplay = MainWindow(title)
private val display = Display(0xd000, 0xd00a, hostDisplay, ScreenDefs.SCREEN_WIDTH_CHARS, ScreenDefs.SCREEN_HEIGHT_CHARS)
private val display = Display(0xd000, 0xd00a, hostDisplay, ScreenDefs.COLUMNS, ScreenDefs.ROWS)
private val mouse = Mouse(0xd300, 0xd305, hostDisplay)
private val keyboard = Keyboard(0xd400, 0xd400, hostDisplay)
private var paused = false
@ -65,6 +65,11 @@ class VirtualMachine(title: String) : IVirtualMachine {
while (cpu.instrCycles > 0) bus.clock()
}
override fun reset() {
bus.reset()
hostDisplay.reset()
}
override fun executeMonitorCommand(command: String) = monitor.command(command)
fun start() {

View File

@ -0,0 +1,138 @@
package razorvine.fonts
import java.awt.Color
import java.awt.Graphics2D
import java.awt.Transparency
import java.awt.image.BufferedImage
import java.io.File
import java.io.FileInputStream
import java.io.IOException
import java.util.zip.GZIPInputStream
class PsfFont(name: String) {
// font format info: https://www.win.tue.nl/~aeb/linux/kbd/font-formats-1.html
val numChars: Int
val bytesPerChar: Int
val height: Int
val width: Int
private val hasUnicodeTable: Boolean
private val rawBitmaps: List<ByteArray>
init {
val data: ByteArray
val fontsDirectory = "/usr/share/kbd/consolefonts"
var stream = javaClass.getResourceAsStream("/charset/$name.psfu.gz") ?:
javaClass.getResourceAsStream("/charset/$name.psf.gz") ?:
(if(File("$fontsDirectory/$name.psfu.gz").exists()) FileInputStream("$fontsDirectory/$name.psfu.gz") else null ) ?:
(if(File("$fontsDirectory/$name.psf.gz").exists()) FileInputStream("$fontsDirectory/$name.psf.gz") else null ) ?:
(if(File("$fontsDirectory/$name.fnt.gz").exists()) FileInputStream("$fontsDirectory/$name.fnt.gz") else null )
if(stream==null) {
stream = javaClass.getResourceAsStream("/charset/$name.psfu") ?:
javaClass.getResourceAsStream("/charset/$name.psf") ?:
(if(File("$fontsDirectory/$name.psfu").exists()) FileInputStream("$fontsDirectory/$name.psfu") else null ) ?:
(if(File("$fontsDirectory/$name.psf").exists()) FileInputStream("$fontsDirectory/$name.psf") else null ) ?:
(if(File("$fontsDirectory/$name.fnt").exists()) FileInputStream("$fontsDirectory/$name.fnt") else null ) ?:
throw IOException("no such font: $name")
data = stream.readBytes()
} else {
GZIPInputStream(stream).use { data = it.readBytes() }
}
stream.close()
if (data[0] == 0x36.toByte() && data[1] == 0x04.toByte()) {
// continue reading PSF1 font
val mode = data[2].toInt()
numChars = if (mode and 1 != 0) 512 else 256
bytesPerChar = data[3].toInt()
hasUnicodeTable = mode and 2 != 0
height = bytesPerChar
width = 8
rawBitmaps = (0..numChars).map {
data.sliceArray(3+it*bytesPerChar..3+(it+1)*bytesPerChar)
}
// ignore unicode table for now: val table = stream.readAllBytes()
} else {
if (data[0] == 0x72.toByte() && data[1] == 0xb5.toByte() && data[2] == 0x4a.toByte() && data[3] == 0x86.toByte()) {
// continue reading PSF2 font
// skip the version val version = makeInt(data, 4)
val headersize = makeInt(data, 8)
val flags = makeInt(data, 12)
hasUnicodeTable = flags and 1 != 0
numChars = makeInt(data, 16)
bytesPerChar = makeInt(data, 20)
height = makeInt(data, 24)
width = makeInt(data, 28)
rawBitmaps = (0..numChars).map {
data.sliceArray(headersize+it*bytesPerChar..headersize+(it+1)*bytesPerChar)
}
} else {
hasUnicodeTable = false
numChars = 0
bytesPerChar = 0
height = 0
width = 0
rawBitmaps = emptyList()
}
}
}
fun convertToImage(gfx: Graphics2D, textColor: Color): BufferedImage {
// create a single image with all the characters in a vertical column from top to bottom.
val bitmap = gfx.deviceConfiguration.createCompatibleImage((width+7) and 0b11111000, height*numChars, Transparency.BITMASK)
val bytesHoriz = (width+7)/8
val color = textColor.rgb
val nopixel = Color(0, 0, 0, 0).rgb
for (char in 0 until numChars) {
for (b in 0 until bytesPerChar) {
val c = rawBitmaps[char][b].toInt()
val ix = 8*(b%bytesHoriz)
val iy = b/bytesHoriz+char*height
bitmap.setRGB(ix, iy, if (c and 0b10000000 != 0) color else nopixel)
bitmap.setRGB(ix+1, iy, if (c and 0b01000000 != 0) color else nopixel)
bitmap.setRGB(ix+2, iy, if (c and 0b00100000 != 0) color else nopixel)
bitmap.setRGB(ix+3, iy, if (c and 0b00010000 != 0) color else nopixel)
bitmap.setRGB(ix+4, iy, if (c and 0b00001000 != 0) color else nopixel)
bitmap.setRGB(ix+5, iy, if (c and 0b00000100 != 0) color else nopixel)
bitmap.setRGB(ix+6, iy, if (c and 0b00000010 != 0) color else nopixel)
bitmap.setRGB(ix+7, iy, if (c and 0b00000001 != 0) color else nopixel)
}
}
return bitmap
}
private fun makeInt(bytes: ByteArray, offset: Int) =
makeInt(bytes[offset], bytes[offset+1], bytes[offset+2], bytes[offset+3])
private fun makeInt(b0: Byte, b1: Byte, b2: Byte, b3: Byte) =
b0.toInt() or (b1.toInt() shl 8) or (b2.toInt() shl 16) or (b3.toInt() shl 24)
}
// private fun loadFallbackCharacters(): Array<BufferedImage> {
// val img = ImageIO.read(javaClass.getResourceAsStream("/charset/unscii8x16.png"))
// val charactersImage = BufferedImage(img.width, img.height, BufferedImage.TYPE_INT_ARGB)
// charactersImage.createGraphics().drawImage(img, 0, 0, null)
//
// val black = Color(0, 0, 0).rgb
// val foreground = FG_COLOR.rgb
// val nopixel = Color(0, 0, 0, 0).rgb
// for (y in 0 until charactersImage.height) {
// for (x in 0 until charactersImage.width) {
// val col = charactersImage.getRGB(x, y)
// if (col == black) charactersImage.setRGB(x, y, nopixel)
// else charactersImage.setRGB(x, y, foreground)
// }
// }
//
// val numColumns = charactersImage.width/8
// val charImages = (0..255).map {
// val charX = it%numColumns
// val charY = it/numColumns
// charactersImage.getSubimage(charX*8, charY*16, 8, 16)
// }
//
// return charImages.toTypedArray()
// }

View File

@ -0,0 +1,237 @@
package razorvine.ksim65
import razorvine.ksim65.components.Address
import razorvine.ksim65.components.MemMappedComponent
class Assembler(cpu: Cpu6502, val memory: MemMappedComponent, initialStartAddress: Address? = null) {
companion object {
fun parseRelativeToPC(relative: String, currentAddress: Int): Int {
val rest = relative.substring(1).trim()
if(rest.isNotEmpty()) {
return when(rest[0]) {
'-' -> currentAddress-parseNumber(rest.substring(1))
'+' -> currentAddress+parseNumber(rest.substring(1))
else -> throw NumberFormatException("invalid address syntax")
}
}
return currentAddress
}
fun parseNumber(number: String, decimalFirst: Boolean = false): Int {
val num = number.trim()
if (num.isBlank()) return 0
if (decimalFirst && num[0].isDigit()) return num.toInt(10)
return when (num[0]) {
'$' -> num.substring(1).trimStart().toInt(16)
'#' -> num.substring(1).trimStart().toInt(10)
'%' -> num.substring(1).trimStart().toInt(2)
else -> num.toInt(16)
}
}
}
private var startAddress = initialStartAddress ?: 0
private var assembledSize = 0
private val instructions by lazy {
val instr = cpu.instructions.withIndex().associate {
Pair(it.value.mnemonic, it.value.mode) to it.index
}.toMutableMap()
instr[Pair("nop", Cpu6502.AddrMode.Imp)] = 0xea
instr.toMap()
}
class Result(val success: Boolean, val error: String, val startAddress: Address, val numBytes: Int)
fun assemble(lines: Iterable<String>): Result {
for(line in lines) {
val result = assemble(line)
if(!result.success)
return result
assembledSize += result.numBytes
}
return Result(true, "", startAddress, assembledSize)
}
fun assemble(line: String): Result {
/*
The command is a line of the form:
"<address> <instruction> [<arguments>]"
" <instruction> [<arguments>]"
"* = <address>"
*/
var args = line.trim().split(' ')
if(args.isEmpty() || args.size == 1 && args[0] == "")
return Result(true, "", startAddress, 0)
if(args[0].startsWith("*=") && args.size==1) {
startAddress = parseNumber(args[0].substring(2))
return Result(true, "", startAddress, 0)
}
else if(args[0] == "*" && args[1] == "=") {
startAddress = parseNumber(args[2])
return Result(true, "", startAddress, 0)
} else {
// line with an instruction, may be preceded by a 4 or 5 char address
if(args[0].length == 4 || args[0].length==5) {
if(args.size!=2 && args.size !=3)
return Result(false, "syntax error", startAddress, 0)
startAddress = parseNumber(args[0])
args = args.drop(1)
}
}
val instructionSize: Int
val mnemonic = args[0].lowercase().trim()
when (args.size) {
1 -> {
// implied or acc
instructionSize = 1
var instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Imp)]
if (instruction == null) instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Acc)]
if (instruction == null) return Result(false, "invalid instruction", this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
}
2 -> {
val arg = args[1]
when {
arg.startsWith('#') -> {
// immediate
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Imm)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = parseNumber(arg.substring(1), decimalFirst = true).toShort()
instructionSize = 2
}
arg.startsWith("(") && arg.endsWith(",x)") -> {
// indirect X
val indAddress = try {
parseNumber(arg.substring(1, arg.length-3))
} catch (x: NumberFormatException) {
return Result(false, "invalid instruction", this.startAddress, 0)
}
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.IzX)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = indAddress.toShort()
instructionSize = 2
}
arg.startsWith("(") && arg.endsWith("),y") -> {
// indirect Y
val indAddress = try {
parseNumber(arg.substring(1, arg.length-3))
} catch (x: NumberFormatException) {
return Result(false, "invalid instruction", this.startAddress, 0)
}
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.IzY)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = indAddress.toShort()
instructionSize = 2
}
arg.endsWith(",x") -> {
// indexed X or zpIndexed X
val indAddress = try {
parseNumber(arg.substring(1, arg.length-2))
} catch (x: NumberFormatException) {
return Result(false, "invalid instruction", this.startAddress, 0)
}
instructionSize = if (indAddress <= 255) {
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.ZpX)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = indAddress.toShort()
2
} else {
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.AbsX)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = (indAddress and 255).toShort()
memory[startAddress+assembledSize+2] = (indAddress ushr 8).toShort()
3
}
}
arg.endsWith(",y") -> {
// indexed Y or zpIndexed Y
val indAddress = try {
parseNumber(arg.substring(1, arg.length-2))
} catch (x: NumberFormatException) {
return Result(false, "invalid instruction", this.startAddress, 0)
}
instructionSize = if (indAddress <= 255) {
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.ZpY)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = indAddress.toShort()
2
} else {
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.AbsY)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = (indAddress and 255).toShort()
memory[startAddress+assembledSize+2] = (indAddress ushr 8).toShort()
3
}
}
arg.endsWith(")") -> {
// indirect (jmp)
val indAddress = try {
parseNumber(arg.substring(1, arg.length-1))
} catch (x: NumberFormatException) {
return Result(false, "invalid instruction", this.startAddress, 0)
}
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Ind)]
?: return Result(false, "invalid instruction", this.startAddress, 0)
memory[startAddress+assembledSize] = instruction.toShort()
memory[startAddress+assembledSize+1] = (indAddress and 255).toShort()
memory[startAddress+assembledSize+2] = (indAddress ushr 8).toShort()
instructionSize = 3
}
else -> {
val instr = instructions[Pair(mnemonic, Cpu6502.AddrMode.Rel)]
if (instr != null) {
// relative address
val rel = try {
parseRelativeToPC(arg, startAddress)
} catch (x: NumberFormatException) {
return Result(false, "invalid numeral", this.startAddress, 0)
}
memory[startAddress+assembledSize] = instr.toShort()
memory[startAddress+assembledSize+1] = (rel-startAddress-2 and 255).toShort()
instructionSize = 2
} else {
// absolute or absZp
val absAddress = try {
if(arg.startsWith('*')) parseRelativeToPC(arg, startAddress) else parseNumber(arg)
} catch (x: NumberFormatException) {
return Result(false, "invalid numeral", this.startAddress, 0)
}
val zpInstruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Zp)]
instructionSize = if (absAddress <= 255 && zpInstruction != null) {
memory[startAddress+assembledSize] = zpInstruction.toShort()
memory[startAddress+assembledSize+1] = absAddress.toShort()
2
} else {
val absInstr = instructions[Pair(mnemonic, Cpu6502.AddrMode.Abs)] ?: return Result(false, "invalid instruction",
this.startAddress, 0)
memory[startAddress+assembledSize] = absInstr.toShort()
memory[startAddress+assembledSize+1] = (absAddress and 255).toShort()
memory[startAddress+assembledSize+2] = (absAddress ushr 8).toShort()
3
}
}
}
}
}
else ->
return Result(false, "syntax error", this.startAddress, 0)
}
return Result(true, "", this.startAddress, instructionSize)
}
}

View File

@ -64,4 +64,8 @@ open class Bus {
it[address-it.startAddress] = data
}
}
fun memoryComponentFor(address: Address) =
memComponents.first { it is MemoryComponent && address >= it.startAddress && address <= it.endAddress } as MemoryComponent
}

View File

@ -7,11 +7,10 @@ import razorvine.ksim65.components.UByte
/**
* 6502 cpu simulation (the NMOS version) including the 'illegal' opcodes.
* TODO: actually implement the illegal opcodes, see http://www.ffd2.com/fridge/docs/6502-NMOS.extra.opcodes or https://sourceforge.net/p/moarnes/code/ci/master/tree/src/6502.c
*/
open class Cpu6502 : BusComponent() {
open val name = "6502"
var tracing: ((state: String) -> Unit)? = null
var tracing: ((state: State) -> Unit)? = null
var totalCycles = 0L
protected set
private var resetTime = System.nanoTime()
@ -29,7 +28,14 @@ open class Cpu6502 : BusComponent() {
class StatusRegister(var C: Boolean = false, var Z: Boolean = false, var I: Boolean = false, var D: Boolean = false,
var B: Boolean = false, var V: Boolean = false, var N: Boolean = false) {
fun asInt(): Int {
return (0b00100000 or (if (N) 0b10000000 else 0) or (if (V) 0b01000000 else 0) or (if (B) 0b00010000 else 0) or (if (D) 0b00001000 else 0) or (if (I) 0b00000100 else 0) or (if (Z) 0b00000010 else 0) or (if (C) 0b00000001 else 0))
return (0b00100000
or (if (N) 0b10000000 else 0)
or (if (V) 0b01000000 else 0)
or (if (B) 0b00010000 else 0)
or (if (D) 0b00001000 else 0)
or (if (I) 0b00000100 else 0)
or (if (Z) 0b00000010 else 0)
or (if (C) 0b00000001 else 0))
}
fun fromInt(byte: Int) {
@ -128,110 +134,11 @@ open class Cpu6502 : BusComponent() {
fun removeBreakpoint(address: Address) = breakpoints.remove(address)
fun disassemble(memory: Array<UByte>, range: IntRange, baseAddress: Address): Pair<List<String>, Address> {
var offset = range.first
val result = mutableListOf<String>()
while (offset <= range.last) {
val dis = disassembleOneInstruction(memory, offset, baseAddress)
result.add(dis.first)
offset += dis.second
}
return Pair(result, offset+baseAddress)
}
fun disassembleOneInstruction(memory: Array<UByte>, offset: Int, baseAddress: Address): Pair<String, Int> {
val spacing1 = " "
val spacing2 = " "
val spacing3 = " "
val byte = memory[offset]
val line = "\$${hexW(offset+baseAddress)} ${hexB(byte)} "
val opcode = instructions[byte.toInt()]
return when (opcode.mode) {
AddrMode.Acc -> {
Pair(line+"$spacing1 ${opcode.mnemonic} a", 1)
}
AddrMode.Imp -> {
Pair(line+"$spacing1 ${opcode.mnemonic}", 1)
}
AddrMode.Imm -> {
val value = memory[offset+1]
Pair(line+"${hexB(value)} $spacing2 ${opcode.mnemonic} #\$${hexB(value)}", 2)
}
AddrMode.Zp -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$${hexB(zpAddr)}", 2)
}
AddrMode.Zpr -> {
// addressing mode used by the 65C02, put here for convenience rather than the subclass
val zpAddr = memory[offset+1]
val rel = memory[offset+2]
val target = (if (rel <= 0x7f) offset+3+rel+baseAddress else offset+3-(256-rel)+baseAddress) and 0xffff
Pair(line+"${hexB(zpAddr)} ${hexB(rel)} $spacing3 ${opcode.mnemonic} \$${hexB(zpAddr)}, \$${hexW(target, true)}", 3)
}
AddrMode.Izp -> {
// addressing mode used by the 65C02, put here for convenience rather than the subclass
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$(${hexB(zpAddr)})", 2)
}
AddrMode.IaX -> {
// addressing mode used by the 65C02, put here for convenience rather than the subclass
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$(${hexW(absAddr)},x)", 3)
}
AddrMode.ZpX -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$${hexB(zpAddr)},x", 2)
}
AddrMode.ZpY -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$${hexB(zpAddr)},y", 2)
}
AddrMode.Rel -> {
val rel = memory[offset+1]
val target = (if (rel <= 0x7f) offset+2+rel+baseAddress else offset+2-(256-rel)+baseAddress) and 0xffff
Pair(line+"${hexB(rel)} $spacing2 ${opcode.mnemonic} \$${hexW(target, true)}", 2)
}
AddrMode.Abs -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$${hexW(absAddr)}", 3)
}
AddrMode.AbsX -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$${hexW(absAddr)},x", 3)
}
AddrMode.AbsY -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$${hexW(absAddr)},y", 3)
}
AddrMode.Ind -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val indirectAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} (\$${hexW(indirectAddr)})", 3)
}
AddrMode.IzX -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} (\$${hexB(zpAddr)},x)", 2)
}
AddrMode.IzY -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} (\$${hexB(zpAddr)}),y", 2)
}
}
}
/**
* Reset the cpu
*/
override fun reset() {
// TODO don't perform all of the reset logic immediately, handle the reset 'pin' in the regular clock() instead (much like a NMI)
regP.I = true
regP.C = false
regP.Z = false
@ -253,10 +160,13 @@ open class Cpu6502 : BusComponent() {
/**
* Process once clock cycle in the cpu.
* Use this if goal is cycle-perfect emulation.
* Use this if you need cycle-perfect instruction timing simulation.
*/
override fun clock() {
if (instrCycles == 0) {
tracing?.invoke(snapshot())
if(nmiAsserted || (irqAsserted && !regP.I)) {
handleInterrupt()
return
@ -268,8 +178,6 @@ open class Cpu6502 : BusComponent() {
currentOpcode = read(regPC)
currentInstruction = instructions[currentOpcode]
// tracing and breakpoint handling
tracing?.invoke(snapshot().toString())
breakpoints[regPC]?.let {
if (breakpoint(it)) return
}
@ -280,9 +188,7 @@ open class Cpu6502 : BusComponent() {
regPC++
instrCycles = currentInstruction.cycles
val extraCycleFromAddr = applyAddressingMode(currentInstruction.mode)
val extraCycleFromInstr = dispatchOpcode(currentOpcode)
if(extraCycleFromAddr and extraCycleFromInstr)
if(applyAddressingMode(currentInstruction.mode) and dispatchOpcode(currentOpcode))
instrCycles++
}
@ -314,7 +220,7 @@ open class Cpu6502 : BusComponent() {
/**
* Execute one single complete instruction.
* Use this when the goal is emulation performance and not a cycle perfect system.
* Use this when you don't care about clock cycle instruction timing simulation.
*/
open fun step() {
totalCycles += instrCycles
@ -649,7 +555,9 @@ open class Cpu6502 : BusComponent() {
val relative = readPc()
fetchedAddress = if (relative >= 0x80) {
regPC-(256-relative) and 0xffff
} else regPC+relative and 0xffff
} else {
regPC+relative and 0xffff
}
false
}
AddrMode.Abs -> {
@ -673,6 +581,7 @@ open class Cpu6502 : BusComponent() {
(fetchedAddress and 0xff00) != hi shl 8
}
AddrMode.Ind -> {
val extraCycle: Boolean
var lo = readPc()
var hi = readPc()
fetchedAddress = lo or (hi shl 8)
@ -681,13 +590,15 @@ open class Cpu6502 : BusComponent() {
// not able to fetch an address which crosses the page boundary.
lo = read(fetchedAddress)
hi = read(fetchedAddress and 0xff00)
extraCycle = true
} else {
// normal behavior
lo = read(fetchedAddress)
hi = read(fetchedAddress+1)
extraCycle = false
}
fetchedAddress = lo or (hi shl 8)
false
extraCycle
}
AddrMode.IzX -> {
// note: not able to fetch an address which crosses the (zero)page boundary
@ -695,15 +606,17 @@ open class Cpu6502 : BusComponent() {
val lo = read((fetchedAddress+regX) and 0xff)
val hi = read((fetchedAddress+regX+1) and 0xff)
fetchedAddress = lo or (hi shl 8)
false
// if this address is a different page, extra clock cycle:
(fetchedAddress and 0xff00) != hi shl 8
}
AddrMode.IzY -> {
// note: not able to fetch an address which crosses the (zero)page boundary
fetchedAddress = readPc()
val lo = read(fetchedAddress)
val hi = read((fetchedAddress+1) and 0xff)
val fetchedAddress1 = readPc()
val lo = read(fetchedAddress1)
val hi = read((fetchedAddress1+1) and 0xff)
fetchedAddress = regY+(lo or (hi shl 8)) and 0xffff
false
// if this address is a different page, extra clock cycle:
(fetchedAddress and 0xff00) != hi shl 8
}
AddrMode.Zpr, AddrMode.Izp, AddrMode.IaX -> {
// addressing mode used by the 65C02 only
@ -713,7 +626,9 @@ open class Cpu6502 : BusComponent() {
}
protected open fun dispatchOpcode(opcode: Int): Boolean {
when (opcode) {
// note: this giant when-statement seems to be the fastest way of doing a jump table like this.
// experiments with an indexed array with function-pointers proved to be several times slower.
return when (opcode) {
0x00 -> iBrk()
0x01 -> iOra()
0x02 -> iInvalid()
@ -970,15 +885,14 @@ open class Cpu6502 : BusComponent() {
0xfd -> iSbc()
0xfe -> iInc()
0xff -> iIsc()
else -> { /* can't occur */ }
else -> false /* can't occur */
}
return false // TODO determine if instructions can cause extra clock cycle
}
// official instructions
protected open fun iAdc() {
protected open fun iAdc(): Boolean {
val operand = getFetched()
if (regP.D) {
// BCD add
@ -1008,15 +922,18 @@ open class Cpu6502 : BusComponent() {
regP.C = tmp > 0xff
regA = tmp and 0xff
}
return true
}
protected fun iAnd() {
protected fun iAnd(): Boolean {
regA = regA and getFetched()
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return true
}
protected fun iAsl() {
protected fun iAsl(): Boolean {
if (currentInstruction.mode == AddrMode.Acc) {
regP.C = (regA and 0b10000000) != 0
regA = (regA shl 1) and 0xff
@ -1030,50 +947,91 @@ open class Cpu6502 : BusComponent() {
regP.Z = shifted == 0
regP.N = (shifted and 0b10000000) != 0
}
return false
}
protected fun iBcc() {
if (!regP.C) regPC = fetchedAddress
protected fun iBcc(): Boolean {
if (!regP.C) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected fun iBcs() {
if (regP.C) regPC = fetchedAddress
protected fun iBcs(): Boolean {
if (regP.C) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected fun iBeq() {
if (regP.Z) regPC = fetchedAddress
protected fun iBeq(): Boolean {
if (regP.Z) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected open fun iBit() {
protected open fun iBit(): Boolean {
val operand = getFetched()
regP.Z = (regA and operand) == 0
regP.V = (operand and 0b01000000) != 0
regP.N = (operand and 0b10000000) != 0
return false
}
protected fun iBmi() {
if (regP.N) regPC = fetchedAddress
protected fun iBmi(): Boolean {
if (regP.N) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected fun iBne() {
if (!regP.Z) regPC = fetchedAddress
protected fun iBne(): Boolean {
if (!regP.Z) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected fun iBpl() {
if (!regP.N) regPC = fetchedAddress
protected fun iBpl(): Boolean {
if (!regP.N) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected open fun iBrk() {
protected open fun iBrk(): Boolean {
// handle BRK ('software interrupt')
regPC++
if(nmiAsserted)
return // if an NMI occurs during BRK, the BRK won't get executed on 6502 (65C02 fixes this)
return false // if an NMI occurs during BRK, the BRK won't get executed on 6502 (65C02 fixes this)
pushStackAddr(regPC)
regP.B = true
pushStack(regP)
regP.I = true // interrupts are now disabled
// NMOS 6502 doesn't clear the D flag (CMOS 65C02 version does...)
regPC = readWord(IRQ_vector)
// TODO prevent NMI from triggering immediately after IRQ/BRK... how does that work exactly?
return false
}
protected open fun handleInterrupt() {
@ -1094,125 +1052,158 @@ open class Cpu6502 : BusComponent() {
regPC = readWord(IRQ_vector)
irqAsserted = false
}
// TODO prevent NMI from triggering immediately after IRQ/BRK... how does that work exactly?
}
protected fun iBvc() {
if (!regP.V) regPC = fetchedAddress
protected fun iBvc(): Boolean {
if (!regP.V) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected fun iBvs() {
if (regP.V) regPC = fetchedAddress
protected fun iBvs(): Boolean {
if (regP.V) {
if(fetchedAddress and 0xff00 != regPC and 0xff00)
instrCycles++
regPC = fetchedAddress
instrCycles++
}
return false
}
protected fun iClc() {
protected fun iClc(): Boolean {
regP.C = false
return false
}
protected fun iCld() {
protected fun iCld(): Boolean {
regP.D = false
return false
}
protected fun iCli() {
protected fun iCli(): Boolean {
regP.I = false
return false
}
protected fun iClv() {
protected fun iClv(): Boolean {
regP.V = false
return false
}
protected fun iCmp() {
val fetched = getFetched()
protected fun iCmp(operandOverride: Int? = null): Boolean {
val fetched = operandOverride ?: getFetched()
regP.C = regA >= fetched
regP.Z = regA == fetched
regP.N = ((regA-fetched) and 0b10000000) != 0
return true
}
protected fun iCpx() {
protected fun iCpx(): Boolean {
val fetched = getFetched()
regP.C = regX >= fetched
regP.Z = regX == fetched
regP.N = ((regX-fetched) and 0b10000000) != 0
return false
}
protected fun iCpy() {
protected fun iCpy(): Boolean {
val fetched = getFetched()
regP.C = regY >= fetched
regP.Z = regY == fetched
regP.N = ((regY-fetched) and 0b10000000) != 0
return false
}
protected open fun iDec() {
protected open fun iDec(): Boolean {
val data = (read(fetchedAddress)-1) and 0xff
write(fetchedAddress, data)
regP.Z = data == 0
regP.N = (data and 0b10000000) != 0
return false
}
protected fun iDex() {
protected fun iDex(): Boolean {
regX = (regX-1) and 0xff
regP.Z = regX == 0
regP.N = (regX and 0b10000000) != 0
return false
}
protected fun iDey() {
protected fun iDey(): Boolean {
regY = (regY-1) and 0xff
regP.Z = regY == 0
regP.N = (regY and 0b10000000) != 0
return false
}
protected fun iEor() {
protected fun iEor(): Boolean {
regA = regA xor getFetched()
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return true
}
protected open fun iInc() {
protected open fun iInc(): Boolean {
val data = (read(fetchedAddress)+1) and 0xff
write(fetchedAddress, data)
regP.Z = data == 0
regP.N = (data and 0b10000000) != 0
return false
}
protected fun iInx() {
protected fun iInx(): Boolean {
regX = (regX+1) and 0xff
regP.Z = regX == 0
regP.N = (regX and 0b10000000) != 0
return false
}
protected fun iIny() {
protected fun iIny(): Boolean {
regY = (regY+1) and 0xff
regP.Z = regY == 0
regP.N = (regY and 0b10000000) != 0
return false
}
protected fun iJmp() {
protected fun iJmp(): Boolean {
regPC = fetchedAddress
return false
}
protected fun iJsr() {
protected fun iJsr(): Boolean {
pushStackAddr(regPC-1)
regPC = fetchedAddress
return false
}
protected fun iLda() {
protected fun iLda(): Boolean {
regA = getFetched()
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return true
}
protected fun iLdx() {
protected fun iLdx(): Boolean {
regX = getFetched()
regP.Z = regX == 0
regP.N = (regX and 0b10000000) != 0
return true
}
protected fun iLdy() {
protected fun iLdy(): Boolean {
regY = getFetched()
regP.Z = regY == 0
regP.N = (regY and 0b10000000) != 0
return true
}
protected fun iLsr() {
protected fun iLsr(): Boolean {
if (currentInstruction.mode == AddrMode.Acc) {
regP.C = (regA and 1) == 1
regA = regA ushr 1
@ -1226,39 +1217,48 @@ open class Cpu6502 : BusComponent() {
regP.Z = shifted == 0
regP.N = (shifted and 0b10000000) != 0
}
return false
}
protected fun iNop() {}
protected fun iNop(): Boolean {
return currentOpcode in listOf(0x1c, 0x3c, 0x5c, 0x7c, 0xdc, 0xfc)
}
protected fun iOra() {
protected fun iOra(): Boolean {
regA = regA or getFetched()
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return true
}
protected fun iPha() {
protected fun iPha(): Boolean {
pushStack(regA)
return false
}
protected fun iPhp() {
protected fun iPhp(): Boolean {
val origBreakflag = regP.B
regP.B = true
pushStack(regP)
regP.B = origBreakflag
return false
}
protected fun iPla() {
protected fun iPla(): Boolean {
regA = popStack()
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return false
}
protected fun iPlp() {
protected fun iPlp(): Boolean {
val previousB = regP.B
regP.fromInt(popStack())
regP.B = true // break is always 1 except when pushing on stack
regP.B = previousB
return false
}
protected fun iRol() {
protected fun iRol(): Boolean {
val oldCarry = regP.C
if (currentInstruction.mode == AddrMode.Acc) {
regP.C = (regA and 0b10000000) != 0
@ -1273,9 +1273,10 @@ open class Cpu6502 : BusComponent() {
regP.Z = shifted == 0
regP.N = (shifted and 0b10000000) != 0
}
return false
}
protected fun iRor() {
protected fun iRor(): Boolean {
val oldCarry = regP.C
if (currentInstruction.mode == AddrMode.Acc) {
regP.C = (regA and 1) == 1
@ -1290,21 +1291,24 @@ open class Cpu6502 : BusComponent() {
regP.Z = shifted == 0
regP.N = (shifted and 0b10000000) != 0
}
return false
}
protected fun iRti() {
protected fun iRti(): Boolean {
regP.fromInt(popStack())
regP.B = true // break is always 1 except when pushing on stack
regP.B = false
regPC = popStackAddr()
return false
}
protected fun iRts() {
protected fun iRts(): Boolean {
regPC = popStackAddr()
regPC = (regPC+1) and 0xffff
return false
}
protected open fun iSbc() {
val operand = getFetched()
protected open fun iSbc(operandOverride: Int? = null): Boolean {
val operand = operandOverride ?: getFetched()
val tmp = (regA-operand-if (regP.C) 0 else 1) and 0xffff
regP.V = (regA xor operand) and (regA xor tmp) and 0b10000000 != 0
if (regP.D) {
@ -1328,142 +1332,209 @@ open class Cpu6502 : BusComponent() {
regP.C = tmp < 0x100
regP.Z = (tmp and 0xff) == 0
regP.N = (tmp and 0b10000000) != 0
return true
}
protected fun iSec() {
protected fun iSec(): Boolean {
regP.C = true
return false
}
protected fun iSed() {
protected fun iSed(): Boolean {
regP.D = true
return false
}
protected fun iSei() {
protected fun iSei(): Boolean {
regP.I = true
return false
}
protected fun iSta() {
protected fun iSta(): Boolean {
write(fetchedAddress, regA)
return false
}
protected fun iStx() {
protected fun iStx(): Boolean {
write(fetchedAddress, regX)
return false
}
protected fun iSty() {
protected fun iSty(): Boolean {
write(fetchedAddress, regY)
return false
}
protected fun iTax() {
protected fun iTax(): Boolean {
regX = regA
regP.Z = regX == 0
regP.N = (regX and 0b10000000) != 0
return false
}
protected fun iTay() {
protected fun iTay(): Boolean {
regY = regA
regP.Z = regY == 0
regP.N = (regY and 0b10000000) != 0
return false
}
protected fun iTsx() {
protected fun iTsx(): Boolean {
regX = regSP
regP.Z = regX == 0
regP.N = (regX and 0b10000000) != 0
return false
}
protected fun iTxa() {
protected fun iTxa(): Boolean {
regA = regX
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return false
}
protected fun iTxs() {
protected fun iTxs(): Boolean {
regSP = regX
return false
}
protected fun iTya() {
protected fun iTya(): Boolean {
regA = regY
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return false
}
// unofficial/illegal 6502 instructions
// unofficial/illegal 6502 instructions now follow
private fun iAhx() {
TODO("\$${hexB(currentOpcode)} - ahx - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
// see http://www.ffd2.com/fridge/docs/6502-NMOS.extra.opcodes
// and http://unusedino.de/ec64/technical/aay/c64/ibmain.htm
// or https://github.com/quietust/nintendulator/blob/master/src/CPU.cpp (search for LogBadOps)
// or https://github.com/stardot/b-em/blob/master/src/6502.c
// or https://github.com/wpmed92/MedNES/blob/master/NES/6502.cpp
// TODO: some of the instructions below may be implemented incorrectly / are not finished yet
private fun iAhx(): Boolean {
val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read)
val value = regA and regX and (addrHi+1)
write(fetchedAddress, value)
return false
}
private fun iAlr() {
TODO("\$${hexB(currentOpcode)} - alr=asr - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iAlr(): Boolean {
iAnd()
iLsr()
return false
}
private fun iAnc() {
TODO("\$${hexB(currentOpcode)} - anc - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iAnc(): Boolean {
iAnd()
regP.C = regP.N
return false
}
private fun iArr() {
TODO("\$${hexB(currentOpcode)} - arr - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iArr(): Boolean {
iAnd()
iRor()
return false
}
private fun iAxs() {
TODO("\$${hexB(currentOpcode)} - axs - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iAxs(): Boolean {
// TODO may not be correct
val oldA = regA
regA = regA and regX
regP.C = false
iSbc()
regX = regA
regA = oldA
return false
}
private fun iDcp() {
TODO("\$${hexB(currentOpcode)} - dcp - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iDcp(): Boolean {
val data = (read(fetchedAddress)-1) and 0xff
write(fetchedAddress, data)
iCmp(data)
return false
}
private fun iIsc() {
TODO("\$${hexB(currentOpcode)} - isc=isb - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iIsc(): Boolean {
val data = (read(fetchedAddress)+1) and 0xff
write(fetchedAddress, data)
iSbc(data)
return false
}
private fun iLas() {
TODO("\$${hexB(currentOpcode)} - las=lar - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iLas(): Boolean {
regA = regSP and getFetched()
regX = regA
regSP = regA
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
return false
}
private fun iLax() {
TODO("\$${hexB(currentOpcode)} - lax - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iLax(): Boolean {
iLda()
regX = regA
return true
}
private fun iRla() {
TODO("\$${hexB(currentOpcode)} - rla - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iRla(): Boolean {
iRol()
iAnd()
return false
}
private fun iRra() {
TODO("\$${hexB(currentOpcode)} - rra - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iRra(): Boolean {
iRor()
iAdc()
return false
}
private fun iSax() {
TODO("\$${hexB(currentOpcode)} - sax - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iSax(): Boolean {
write(fetchedAddress, regA and regX)
return false
}
private fun iShx() {
TODO("\$${hexB(currentOpcode)} - shx - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iShx(): Boolean {
val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read)
write(fetchedAddress, regX and (addrHi+1))
return false
}
private fun iShy() {
TODO("\$${hexB(currentOpcode)} - shy - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iShy(): Boolean {
val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read)
write(fetchedAddress, regY and (addrHi+1))
return false
}
private fun iSlo() {
TODO("\$${hexB(currentOpcode)} - slo=aso - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iSlo(): Boolean {
iAsl()
iOra()
return false
}
private fun iSre() {
TODO("\$${hexB(currentOpcode)} - sre=lse - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iSre(): Boolean {
iLsr()
iEor()
return false
}
private fun iTas() {
TODO("\$${hexB(currentOpcode)} - tas - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iTas(): Boolean {
regSP = regA and regX
val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read)
write(fetchedAddress, regSP and addrHi)
return false
}
private fun iXaa() {
TODO("\$${hexB(currentOpcode)} - xaa - ('illegal' instruction) @ \$${hexW(currentOpcodeAddress)}")
private fun iXaa(): Boolean {
regA = (regX and fetchedData)
return false
}
// invalid instruction (JAM / KIL / HLT)
private fun iInvalid() {
private fun iInvalid(): Boolean {
throw InstructionError("invalid instruction encountered: opcode=${hexB(currentOpcode)} instr=${currentInstruction.mnemonic} @ ${hexW(currentOpcodeAddress)}")
}
}

View File

@ -17,7 +17,7 @@ class Cpu65C02 : Cpu6502() {
/**
* Process once clock cycle in the cpu
* Use this if goal is cycle-perfect emulation.
* Use this if you need cycle-perfect instruction timing simulation.
*/
override fun clock() {
when (waiting) {
@ -40,7 +40,7 @@ class Cpu65C02 : Cpu6502() {
/**
* Execute one single complete instruction.
* Use this when the goal is emulation performance and not a cycle perfect system.
* Use this when you don't care about clock cycle instruction timing simulation.
*/
override fun step() {
totalCycles += instrCycles
@ -103,7 +103,7 @@ class Cpu65C02 : Cpu6502() {
}
override fun dispatchOpcode(opcode: Int): Boolean {
when (opcode) {
return when (opcode) {
0x00 -> iBrk()
0x01 -> iOra()
0x02 -> iNop()
@ -360,9 +360,8 @@ class Cpu65C02 : Cpu6502() {
0xfd -> iSbc()
0xfe -> iInc()
0xff -> iBbs7()
else -> { /* can't occur */ }
else -> false /* can't occur */
}
return false // TODO determine if instructions can cause extra clock cycle
}
// opcode list: http://www.oxyron.de/html/opcodesc02.html
@ -624,7 +623,7 @@ class Cpu65C02 : Cpu6502() {
/* fe */ Instruction("inc", AddrMode.AbsX, 7),
/* ff */ Instruction("bbs7", AddrMode.Zpr, 5)).toTypedArray()
override fun iBrk() {
override fun iBrk(): Boolean {
// handle BRK ('software interrupt')
regPC++
pushStackAddr(regPC)
@ -633,6 +632,9 @@ class Cpu65C02 : Cpu6502() {
regP.I = true // interrupts are now disabled
regP.D = false // this is different from NMOS 6502
regPC = readWord(IRQ_vector)
// TODO prevent NMI from triggering immediately after IRQ/BRK... how does that work exactly?
return false
}
override fun handleInterrupt() {
@ -640,16 +642,17 @@ class Cpu65C02 : Cpu6502() {
regP.D = false // this is different from NMOS 6502
}
override fun iBit() {
override fun iBit(): Boolean {
val data = getFetched()
regP.Z = (regA and data) == 0
if (currentInstruction.mode != AddrMode.Imm) {
regP.V = (data and 0b01000000) != 0
regP.N = (data and 0b10000000) != 0
}
return false
}
override fun iAdc() {
override fun iAdc(): Boolean {
val value = getFetched()
if (regP.D) {
// BCD add
@ -678,13 +681,14 @@ class Cpu65C02 : Cpu6502() {
regP.C = tmp > 0xff
regA = tmp and 0xff
}
return false
}
override fun iSbc() {
override fun iSbc(operandOverride: Int?): Boolean {
// see http://www.6502.org/tutorials/decimal_mode.html
// and https://sourceforge.net/p/vice-emu/code/HEAD/tree/trunk/vice/src/65c02core.c#l1205
// (the implementation below is based on the code used by Vice)
val value = getFetched()
val value = operandOverride ?: getFetched()
var tmp = (regA-value-if (regP.C) 0 else 1) and 0xffff
regP.V = (regA xor tmp) and (regA xor value) and 0b10000000 != 0
if (regP.D) {
@ -696,230 +700,323 @@ class Cpu65C02 : Cpu6502() {
regP.Z = (tmp and 0xff) == 0
regP.N = (tmp and 0b10000000) != 0
regA = tmp and 0xff
return false
}
override fun iDec() {
if (currentInstruction.mode == AddrMode.Acc) {
override fun iDec(): Boolean {
return if (currentInstruction.mode == AddrMode.Acc) {
regA = (regA-1) and 0xff
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
false
} else super.iDec()
}
override fun iInc() {
if (currentInstruction.mode == AddrMode.Acc) {
override fun iInc(): Boolean {
return if (currentInstruction.mode == AddrMode.Acc) {
regA = (regA+1) and 0xff
regP.Z = regA == 0
regP.N = (regA and 0b10000000) != 0
false
} else super.iInc()
}
private fun iBra() {
private fun iBra(): Boolean {
// unconditional branch
regPC = fetchedAddress
return false
}
private fun iTrb() {
private fun iTrb(): Boolean {
val data = getFetched()
regP.Z = data and regA == 0
write(fetchedAddress, data and regA.inv())
return false
}
private fun iTsb() {
private fun iTsb(): Boolean {
val data = getFetched()
regP.Z = data and regA == 0
write(fetchedAddress, data or regA)
return false
}
private fun iStz() {
private fun iStz(): Boolean {
write(fetchedAddress, 0)
return false
}
private fun iWai() {
private fun iWai(): Boolean {
waiting = Wait.Waiting
return false
}
private fun iStp() {
private fun iStp(): Boolean {
waiting = Wait.Stopped
return false
}
private fun iPhx() {
private fun iPhx(): Boolean {
pushStack(regX)
return false
}
private fun iPlx() {
private fun iPlx(): Boolean {
regX = popStack()
regP.Z = regX == 0
regP.N = (regX and 0b10000000) != 0
return false
}
private fun iPhy() {
private fun iPhy(): Boolean {
pushStack(regY)
return false
}
private fun iPly() {
private fun iPly(): Boolean {
regY = popStack()
regP.Z = regY == 0
regP.N = (regY and 0b10000000) != 0
return false
}
private fun iBbr0() {
private fun iBbr0(): Boolean {
val data = getFetched()
if (data and 1 == 0) regPC = fetchedAddressZpr
if (data and 1 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr1() {
private fun iBbr1(): Boolean {
val data = getFetched()
if (data and 2 == 0) regPC = fetchedAddressZpr
if (data and 2 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr2() {
private fun iBbr2(): Boolean {
val data = getFetched()
if (data and 4 == 0) regPC = fetchedAddressZpr
if (data and 4 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr3() {
private fun iBbr3(): Boolean {
val data = getFetched()
if (data and 8 == 0) regPC = fetchedAddressZpr
if (data and 8 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr4() {
private fun iBbr4(): Boolean {
val data = getFetched()
if (data and 16 == 0) regPC = fetchedAddressZpr
if (data and 16 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr5() {
private fun iBbr5(): Boolean {
val data = getFetched()
if (data and 32 == 0) regPC = fetchedAddressZpr
if (data and 32 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr6() {
private fun iBbr6(): Boolean {
val data = getFetched()
if (data and 64 == 0) regPC = fetchedAddressZpr
if (data and 64 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbr7() {
private fun iBbr7(): Boolean {
val data = getFetched()
if (data and 128 == 0) regPC = fetchedAddressZpr
if (data and 128 == 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs0() {
private fun iBbs0(): Boolean {
val data = getFetched()
if (data and 1 != 0) regPC = fetchedAddressZpr
if (data and 1 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs1() {
private fun iBbs1(): Boolean {
val data = getFetched()
if (data and 2 != 0) regPC = fetchedAddressZpr
if (data and 2 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs2() {
private fun iBbs2(): Boolean {
val data = getFetched()
if (data and 4 != 0) regPC = fetchedAddressZpr
if (data and 4 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs3() {
private fun iBbs3(): Boolean {
val data = getFetched()
if (data and 8 != 0) regPC = fetchedAddressZpr
if (data and 8 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs4() {
private fun iBbs4(): Boolean {
val data = getFetched()
if (data and 16 != 0) regPC = fetchedAddressZpr
if (data and 16 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs5() {
private fun iBbs5(): Boolean {
val data = getFetched()
if (data and 32 != 0) regPC = fetchedAddressZpr
if (data and 32 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs6() {
private fun iBbs6(): Boolean {
val data = getFetched()
if (data and 64 != 0) regPC = fetchedAddressZpr
if (data and 64 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iBbs7() {
private fun iBbs7(): Boolean {
val data = getFetched()
if (data and 128 != 0) regPC = fetchedAddressZpr
if (data and 128 != 0) {
regPC = fetchedAddressZpr
instrCycles++
}
return false
}
private fun iSmb0() {
private fun iSmb0(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 1)
return false
}
private fun iSmb1() {
private fun iSmb1(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 2)
return false
}
private fun iSmb2() {
private fun iSmb2(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 4)
return false
}
private fun iSmb3() {
private fun iSmb3(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 8)
return false
}
private fun iSmb4() {
private fun iSmb4(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 16)
return false
}
private fun iSmb5() {
private fun iSmb5(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 32)
return false
}
private fun iSmb6() {
private fun iSmb6(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 64)
return false
}
private fun iSmb7() {
private fun iSmb7(): Boolean {
val data = getFetched()
write(fetchedAddress, data or 128)
return false
}
private fun iRmb0() {
private fun iRmb0(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b11111110)
return false
}
private fun iRmb1() {
private fun iRmb1(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b11111101)
return false
}
private fun iRmb2() {
private fun iRmb2(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b11111011)
return false
}
private fun iRmb3() {
private fun iRmb3(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b11110111)
return false
}
private fun iRmb4() {
private fun iRmb4(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b11101111)
return false
}
private fun iRmb5() {
private fun iRmb5(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b11011111)
return false
}
private fun iRmb6() {
private fun iRmb6(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b10111111)
return false
}
private fun iRmb7() {
private fun iRmb7(): Boolean {
val data = getFetched()
write(fetchedAddress, data and 0b01111111)
return false
}
}

View File

@ -0,0 +1,110 @@
package razorvine.ksim65
import razorvine.ksim65.components.Address
import razorvine.ksim65.components.UByte
class Disassembler(cpu: Cpu6502) {
private val instructions = cpu.instructions
fun disassemble(memory: Array<UByte>, range: IntRange, baseAddress: Address): Pair<List<String>, Address> {
var offset = range.first
val result = mutableListOf<String>()
while (offset <= range.last) {
val dis = disassembleOneInstruction(memory, offset, baseAddress)
result.add(dis.first)
offset += dis.second
}
return Pair(result, offset+baseAddress)
}
fun disassembleOneInstruction(memory: Array<UByte>, offset: Int, baseAddress: Address): Pair<String, Int> {
val spacing1 = " "
val spacing2 = " "
val spacing3 = " "
val byte = memory[offset]
val line = "\$${hexW(offset+baseAddress)} ${hexB(byte)} "
val opcode = instructions[byte.toInt()]
return when (opcode.mode) {
Cpu6502.AddrMode.Acc -> {
Pair(line+"$spacing1 ${opcode.mnemonic} a", 1)
}
Cpu6502.AddrMode.Imp -> {
Pair(line+"$spacing1 ${opcode.mnemonic}", 1)
}
Cpu6502.AddrMode.Imm -> {
val value = memory[offset+1]
Pair(line+"${hexB(value)} $spacing2 ${opcode.mnemonic} #\$${hexB(value)}", 2)
}
Cpu6502.AddrMode.Zp -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$${hexB(zpAddr)}", 2)
}
Cpu6502.AddrMode.Zpr -> {
// addressing mode used by the 65C02, put here for convenience rather than the subclass
val zpAddr = memory[offset+1]
val rel = memory[offset+2]
val target = (if (rel <= 0x7f) offset+3+rel+baseAddress else offset+3-(256-rel)+baseAddress) and 0xffff
Pair(line+"${hexB(zpAddr)} ${hexB(rel)} $spacing3 ${opcode.mnemonic} \$${hexB(zpAddr)}, \$${hexW(target, true)}", 3)
}
Cpu6502.AddrMode.Izp -> {
// addressing mode used by the 65C02, put here for convenience rather than the subclass
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$(${hexB(zpAddr)})", 2)
}
Cpu6502.AddrMode.IaX -> {
// addressing mode used by the 65C02, put here for convenience rather than the subclass
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$(${hexW(absAddr)},x)", 3)
}
Cpu6502.AddrMode.ZpX -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$${hexB(zpAddr)},x", 2)
}
Cpu6502.AddrMode.ZpY -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} \$${hexB(zpAddr)},y", 2)
}
Cpu6502.AddrMode.Rel -> {
val rel = memory[offset+1]
val target = (if (rel <= 0x7f) offset+2+rel+baseAddress else offset+2-(256-rel)+baseAddress) and 0xffff
Pair(line+"${hexB(rel)} $spacing2 ${opcode.mnemonic} \$${hexW(target, true)}", 2)
}
Cpu6502.AddrMode.Abs -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$${hexW(absAddr)}", 3)
}
Cpu6502.AddrMode.AbsX -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$${hexW(absAddr)},x", 3)
}
Cpu6502.AddrMode.AbsY -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val absAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} \$${hexW(absAddr)},y", 3)
}
Cpu6502.AddrMode.Ind -> {
val lo = memory[offset+1]
val hi = memory[offset+2]
val indirectAddr = lo.toInt() or (hi.toInt() shl 8)
Pair(line+"${hexB(lo)} ${hexB(hi)} $spacing3 ${opcode.mnemonic} (\$${hexW(indirectAddr)})", 3)
}
Cpu6502.AddrMode.IzX -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} (\$${hexB(zpAddr)},x)", 2)
}
Cpu6502.AddrMode.IzY -> {
val zpAddr = memory[offset+1]
Pair(line+"${hexB(zpAddr)} $spacing2 ${opcode.mnemonic} (\$${hexB(zpAddr)}),y", 2)
}
}
}
}

View File

@ -7,6 +7,7 @@ import java.io.File
interface IVirtualMachine {
fun step()
fun pause(paused: Boolean)
fun reset()
fun getZeroAndStackPages(): Array<UByte>
fun loadFileInRam(file: File, loadAddress: Address?)

View File

@ -4,13 +4,7 @@ import kotlin.math.max
class Monitor(val bus: Bus, val cpu: Cpu6502) {
private val instructions by lazy {
val instr = cpu.instructions.withIndex().associate {
Pair(it.value.mnemonic, it.value.mode) to it.index
}.toMutableMap()
instr[Pair("nop", Cpu6502.AddrMode.Imp)] = 0xea
instr.toMap()
}
private val disassembler = Disassembler(cpu)
fun command(command: String): IVirtualMachine.MonitorCmdResult {
if (command.isEmpty()) return IVirtualMachine.MonitorCmdResult("", "", false)
@ -24,9 +18,9 @@ class Monitor(val bus: Bus, val cpu: Cpu6502) {
val parts = command.substring(1).trim().split(' ')
if (parts.size != 3) IVirtualMachine.MonitorCmdResult("?syntax error", command, false)
else {
val start = parseNumber(parts[0])
val end = parseNumber(parts[1])
val value = parseNumber(parts[2]).toShort()
val start = Assembler.parseNumber(parts[0])
val end = Assembler.parseNumber(parts[1])
val value = Assembler.parseNumber(parts[2]).toShort()
for (addr in start..end) {
bus.write(addr, value)
}
@ -35,12 +29,12 @@ class Monitor(val bus: Bus, val cpu: Cpu6502) {
}
'm' -> {
val addresses = command.substring(1).trim().split(' ')
val start = parseNumber(addresses[0])
val end = if (addresses.size > 1) parseNumber(addresses[1]) else start+1
val start = Assembler.parseNumber(addresses[0])
val end = if (addresses.size > 1) Assembler.parseNumber(addresses[1]) else start+1
val result = mutableListOf<String>()
for (addr in start until end step 16) {
result.add("m$${hexW(addr)} "+(0..15).joinToString(" ") { hexB(bus.read(addr+it)) }+" "+(0..15).joinToString("") {
val chr = bus.read(addr+it).toChar()
val chr = bus.read(addr+it).toInt().toChar()
if (chr.isLetterOrDigit()) chr.toString()
else "."
})
@ -49,19 +43,19 @@ class Monitor(val bus: Bus, val cpu: Cpu6502) {
}
'p' -> {
val numbers = command.substring(1).trim().split(' ')
val address = parseNumber(numbers[0])
val values = numbers.drop(1).map { parseNumber(it) }
val address = Assembler.parseNumber(numbers[0])
val values = numbers.drop(1).map { Assembler.parseNumber(it) }
values.forEachIndexed { index, i -> bus.write(address+index, i.toShort()) }
IVirtualMachine.MonitorCmdResult("ok", "", true)
}
'i' -> {
val addresses = command.substring(1).trim().split(' ')
val start = parseNumber(addresses[0])
val end = if (addresses.size > 1) parseNumber(addresses[1]) else start+1
val start = Assembler.parseNumber(addresses[0])
val end = if (addresses.size > 1) Assembler.parseNumber(addresses[1]) else start+1
val result = mutableListOf<String>()
for (addr in start until end step 64) {
result.add("i$${hexW(addr)} "+(0..63).joinToString("") {
val chr = bus.read(addr+it).toChar()
val chr = bus.read(addr+it).toInt().toChar()
if (chr.isLetterOrDigit()) chr.toString()
else "."
})
@ -69,35 +63,44 @@ class Monitor(val bus: Bus, val cpu: Cpu6502) {
IVirtualMachine.MonitorCmdResult(result.joinToString("\n"), "", true)
}
'$' -> {
val number = parseNumber(command)
val number = Assembler.parseNumber(command)
val output = "$${hexW(number)} #$number %${number.toString(2)}"
IVirtualMachine.MonitorCmdResult(output, "", true)
}
'#' -> {
val number = parseNumber(command)
val number = Assembler.parseNumber(command)
val output = "$${hexW(number)} #$number %${number.toString(2)}"
IVirtualMachine.MonitorCmdResult(output, "", true)
}
'%' -> {
val number = parseNumber(command)
val number = Assembler.parseNumber(command)
val output = "$${hexW(number)} #$number %${number.toString(2)}"
IVirtualMachine.MonitorCmdResult(output, "", true)
}
'g' -> {
val address = parseNumber(command.substring(1))
val address = Assembler.parseNumber(command.substring(1))
cpu.regPC = address
IVirtualMachine.MonitorCmdResult("", "", true)
}
'a' -> {
val parts = command.substring(1).trim().split(' ')
assemble(command, parts)
val address = if(parts.size>=2) Assembler.parseNumber(parts[0]) else 0
val assembler = Assembler(cpu, bus.memoryComponentFor(address), address)
val result = assembler.assemble(command.substring(1).trimStart())
if(result.success) {
val memory = (result.startAddress..result.startAddress+result.numBytes).map { bus[it] }.toTypedArray()
val d = disassembler.disassembleOneInstruction(memory, 0, result.startAddress)
IVirtualMachine.MonitorCmdResult(d.first, "a$${hexW(result.startAddress+result.numBytes)} ", false)
}
else
IVirtualMachine.MonitorCmdResult(result.error, command, false)
}
'd' -> {
val addresses = command.substring(1).trim().split(' ')
val start = parseNumber(addresses[0])
val end = if (addresses.size > 1) parseNumber(addresses[1]) else start
val start = Assembler.parseNumber(addresses[0])
val end = if (addresses.size > 1) Assembler.parseNumber(addresses[1]) else start
val memory = (start .. max(0xffff, end+3)).map {bus[it]}.toTypedArray()
val disassem = cpu.disassemble(memory, 0 .. end-start, start)
val disassem = disassembler.disassemble(memory, 0 .. end-start, start)
IVirtualMachine.MonitorCmdResult(disassem.first.joinToString("\n") { "d$it" }, "d$${hexW(disassem.second)}", false)
}
else -> {
@ -105,164 +108,4 @@ class Monitor(val bus: Bus, val cpu: Cpu6502) {
}
}
}
private fun assemble(command: String, parts: List<String>): IVirtualMachine.MonitorCmdResult {
if (parts.size < 2) return IVirtualMachine.MonitorCmdResult("done", "", false)
val address = parseNumber(parts[0])
val mnemonic = parts[1].toLowerCase()
when (parts.size) {
2 -> {
// implied or acc
var instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Imp)]
if (instruction == null) instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Acc)]
if (instruction == null) return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
}
3 -> {
val arg = parts[2]
when {
arg.startsWith('#') -> {
// immediate
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Imm)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, parseNumber(arg.substring(1), decimalFirst = true).toShort())
}
arg.startsWith("(") && arg.endsWith(",x)") -> {
// indirect X
val indAddress = try {
parseNumber(arg.substring(1, arg.length-3))
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.IzX)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, indAddress.toShort())
}
arg.startsWith("(") && arg.endsWith("),y") -> {
// indirect Y
val indAddress = try {
parseNumber(arg.substring(1, arg.length-3))
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.IzY)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, indAddress.toShort())
}
arg.endsWith(",x") -> {
// indexed X or zpIndexed X
val indAddress = try {
parseNumber(arg.substring(1, arg.length-2))
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
if (indAddress <= 255) {
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.ZpX)] ?: return IVirtualMachine.MonitorCmdResult(
"?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, indAddress.toShort())
} else {
val instruction =
instructions[Pair(mnemonic, Cpu6502.AddrMode.AbsX)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, (indAddress and 255).toShort())
bus.write(address+2, (indAddress ushr 8).toShort())
}
}
arg.endsWith(",y") -> {
// indexed Y or zpIndexed Y
val indAddress = try {
parseNumber(arg.substring(1, arg.length-2))
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
if (indAddress <= 255) {
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.ZpY)] ?: return IVirtualMachine.MonitorCmdResult(
"?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, indAddress.toShort())
} else {
val instruction =
instructions[Pair(mnemonic, Cpu6502.AddrMode.AbsY)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, (indAddress and 255).toShort())
bus.write(address+2, (indAddress ushr 8).toShort())
}
}
arg.endsWith(")") -> {
// indirect (jmp)
val indAddress = try {
parseNumber(arg.substring(1, arg.length-1))
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
val instruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Ind)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, instruction.toShort())
bus.write(address+1, (indAddress and 255).toShort())
bus.write(address+2, (indAddress ushr 8).toShort())
}
else -> {
val instr = instructions[Pair(mnemonic, Cpu6502.AddrMode.Rel)]
if (instr != null) {
// relative address
val rel = try {
parseRelativeToPC(arg, address)
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
bus.write(address, instr.toShort())
bus.write(address+1, (rel-address-2 and 255).toShort())
} else {
// absolute or absZp
val absAddress = try {
if(arg.startsWith('*')) parseRelativeToPC(arg, address) else parseNumber(arg)
} catch (x: NumberFormatException) {
return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
}
val zpInstruction = instructions[Pair(mnemonic, Cpu6502.AddrMode.Zp)]
if (absAddress <= 255 && zpInstruction!=null) {
bus.write(address, zpInstruction.toShort())
bus.write(address+1, absAddress.toShort())
} else {
val absInstr = instructions[Pair(mnemonic, Cpu6502.AddrMode.Abs)] ?: return IVirtualMachine.MonitorCmdResult("?invalid instruction", command, false)
bus.write(address, absInstr.toShort())
bus.write(address+1, (absAddress and 255).toShort())
bus.write(address+2, (absAddress ushr 8).toShort())
}
}
}
}
}
else -> return IVirtualMachine.MonitorCmdResult("?syntax error", command, false)
}
val memory = listOf(bus[address], bus[address+1], bus[address+2]).toTypedArray()
val disassem = cpu.disassembleOneInstruction(memory, 0, address)
return IVirtualMachine.MonitorCmdResult(disassem.first, "a$${hexW(disassem.second + address)} ", false)
}
private fun parseRelativeToPC(relative: String, currentAddress: Int): Int {
val rest = relative.substring(1).trim()
if(rest.isNotEmpty()) {
return when(rest[0]) {
'-' -> currentAddress-parseNumber(rest.substring(1))
'+' -> currentAddress+parseNumber(rest.substring(1))
else -> throw Cpu6502.InstructionError("invalid address syntax")
}
}
return currentAddress
}
private fun parseNumber(number: String, decimalFirst: Boolean = false): Int {
val num = number.trim()
if (num.isBlank()) return 0
if (decimalFirst && num[0].isDigit()) return num.toInt(10)
return when (num[0]) {
'$' -> num.substring(1).trimStart().toInt(16)
'#' -> num.substring(1).trimStart().toInt(10)
'%' -> num.substring(1).trimStart().toInt(2)
else -> num.toInt(16)
}
}
}

View File

@ -2,20 +2,16 @@ package razorvine.ksim65
import razorvine.ksim65.components.Address
fun hexW(number: Address, allowSingleByte: Boolean = false): String {
val msb = number ushr 8
val lsb = number and 0xff
return if (msb == 0 && allowSingleByte) hexB(lsb)
else hexB(msb)+hexB(lsb)
}
fun hexW(number: Int, allowSingleByte: Boolean = false) =
if(allowSingleByte && (number and 0xff00 == 0)) {
number.toString(16).padStart(2, '0')
} else {
number.toString(16).padStart(4, '0')
}
fun hexB(number: Short): String = hexB(number.toInt())
fun hexB(number: Int): String {
val hexdigits = "0123456789abcdef"
val loNibble = number and 15
val hiNibble = (number and 65535) ushr 4
return hexdigits[hiNibble].toString()+hexdigits[loNibble]
}
fun hexB(number: Int) = number.toString(16).padStart(2, '0')
fun hexB(number: Short) = hexB(number.toInt())
typealias BreakpointHandler = (cpu: Cpu6502, pc: Address) -> Cpu6502.BreakpointResultAction

View File

@ -45,7 +45,7 @@ abstract class MemMappedComponent(val startAddress: Address, val endAddress: Add
}
print(" ")
val chars = if (charmapper != null) bytes.map { b -> charmapper(b) }
else bytes.map { b -> if (b in 32..255) b.toChar() else '.' }
else bytes.map { b -> if (b in 32..255) b.toInt().toChar() else '.' }
println(chars.joinToString(""))
}
}

View File

@ -52,7 +52,7 @@ class Display(startAddress: Address, endAddress: Address, private val host: IHos
}
override fun reset() {
charMatrix.forEach { it.fill(' '.toShort()) }
charMatrix.forEach { it.fill(' '.code.toShort()) }
cursorX = 0
cursorY = 0
charposX = 0
@ -94,7 +94,7 @@ class Display(startAddress: Address, endAddress: Address, private val host: IHos
0x02 -> {
if (charposY in 0 until charHeight && charposX in 0 until charWidth) {
charMatrix[charposY][charposX] = data
host.setChar(charposX, charposY, data.toChar())
host.setChar(charposX, charposY, data.toInt().toChar())
}
}
0x03 -> pixelX = (pixelX and 0xff00) or data.toInt()
@ -102,7 +102,7 @@ class Display(startAddress: Address, endAddress: Address, private val host: IHos
0x05 -> pixelY = (pixelY and 0xff00) or data.toInt()
0x06 -> pixelY = (pixelY and 0x00ff) or (data.toInt() shl 8)
0x07 -> {
if (pixelX in 0 until ScreenDefs.SCREEN_WIDTH && pixelY in 0 until ScreenDefs.SCREEN_HEIGHT) {
if (pixelX in 0 until ScreenDefs.COLUMNS*charWidth && pixelY in 0 until ScreenDefs.ROWS*charHeight) {
if (data == 0.toShort()) host.clearPixel(pixelX, pixelY)
else host.setPixel(pixelX, pixelY)
}
@ -121,7 +121,7 @@ class Display(startAddress: Address, endAddress: Address, private val host: IHos
cursorX = charWidth-1
}
}
charMatrix[cursorY][cursorX] = ' '.toShort()
charMatrix[cursorY][cursorX] = ' '.code.toShort()
host.setChar(cursorX, cursorY, ' ')
}
0x09 -> {
@ -142,7 +142,7 @@ class Display(startAddress: Address, endAddress: Address, private val host: IHos
else -> {
// set character on screen
charMatrix[cursorY][cursorX] = data
host.setChar(cursorX, cursorY, data.toChar())
host.setChar(cursorX, cursorY, data.toInt().toChar())
cursorX++
if (cursorX >= charWidth) {
cursorX = 0
@ -164,7 +164,7 @@ class Display(startAddress: Address, endAddress: Address, private val host: IHos
charMatrix[y+1].copyInto(charMatrix[y])
}
for (x in 0 until charWidth) {
charMatrix[charHeight-1][x] = ' '.toShort()
charMatrix[charHeight-1][x] = ' '.code.toShort()
}
cursorY--
host.scrollUp()

View File

@ -25,7 +25,7 @@ class Keyboard(startAddress: Address, endAddress: Address, private val host: IHo
override operator fun get(offset: Int): UByte {
return when (offset) {
0x00 -> host.keyboard()?.toShort() ?: 0
0x00 -> host.keyboard()?.code?.toShort() ?: 0
else -> 0xff
}
}

View File

@ -27,7 +27,7 @@ class ParallelPort(startAddress: Address, endAddress: Address) : MemMappedCompon
if (offset == 0) dataByte = data
else if (offset == 1) {
if ((data.toInt() and 1) == 1) {
val char = dataByte.toChar()
val char = dataByte.toInt().toChar()
println("PARALLEL WRITE: '$char'")
}
}

View File

@ -6,7 +6,7 @@ import java.io.File
* A ROM chip (read-only memory).
*/
class Rom(startAddress: Address, endAddress: Address, initialData: Array<UByte>? = null) : MemoryComponent(startAddress, endAddress) {
override val data: Array<UByte> = initialData?.copyOf() ?: Array<UByte>(endAddress-startAddress+1) { 0 }
override val data: Array<UByte> = initialData?.copyOf() ?: Array(endAddress-startAddress+1) { 0 }
init {
require(endAddress-startAddress+1 == data.size) { "rom address range doesn't match size of data bytes" }

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,24 @@
Copyright (c) 2018-2020, Frederic Cambus
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1 +1 @@
version=1.7
version=1.10

View File

@ -0,0 +1,426 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adca"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda pb
and #%00001000
bne decmode
lda db
sta da
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta da
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adcax"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,435 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adcax"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta xb
next lda pb
and #%00001000
bne decmode
lda db
sta da
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta da
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc da,x
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda xb
bne nodec
dec cmd+2
nodec dec xb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adcay"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,435 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adcay"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta yb
next lda pb
and #%00001000
bne decmode
lda db
sta da
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta da
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc da,y
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda yb
bne nodec
dec cmd+2
nodec dec yb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adcix"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,428 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adcb"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda pb
and #%00001000
bne decmode
lda db
sta da
sta dr
sta cmd+1
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta da
sta dr
sta cmd+1
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc #0
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adcz"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,434 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adcix"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta xb
lda #<da
sta 172
lda #>da
sta 173
next lda pb
and #%00001000
bne decmode
lda db
sta da
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta da
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc (172,x)
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
dec xb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adciy"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,439 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adciy"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta yb
lda #<da
sta 172
lda #>da
sta 173
next lda pb
and #%00001000
bne decmode
lda db
sta da
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta da
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc (172),y
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc 172
bne noinc
inc 173
noinc lda yb
bne nodec
dec 173
nodec dec yb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "sbcb"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,428 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adcz"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda pb
and #%00001000
bne decmode
lda db
sta 172
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta 172
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adczx"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,432 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)adczx"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta xb
next lda pb
and #%00001000
bne decmode
lda db
sta 172
sta dr
sta cmd0+1
and #$7f
sta cmd1+1
clc
lda pb
and #1
beq noc
sec
noc php
lda ab
cmd0 adc #0
sta ar
lda pb
ora #%00110000
and #%00111100
bcc noc1
ora #1
noc1 tax
lda ab
and #$7f
plp
cmd1 adc #0
bmi neg
txa
and #1
beq cont
set txa
ora #%01000000
tax
jmp cont
neg txa
and #1
beq set
cont lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
jmp deccont
decmode
.block
lda db
sta 172
sta dr
and #$0f
sta l0+1
lda pb
ora #%00110000
and #%00111100
tax
lda pb
lsr a
lda ab
and #$0f
l0 adc #0
ldy #$00
cmp #$0a
bcc l1
sec
sbc #$0a
and #$0f
ldy #$08
l1 sta ar
sty l2+1
sty l3+1
lda db
and #$f0
ora l3+1
sta l3+1
lda ab
and #$f0
l2 ora #0
clc
l3 adc #0
php
bcs l4
cmp #$a0
bcc l5
l4 sec
sbc #$a0
inx
l5 ora ar
sta ar
plp
bvc nov
php
txa
ora #%01000000
tax
plp
nov bpl non
txa
ora #%10000000
tax
non lda pb
lsr a
lda ab
adc db
bne noz
txa
ora #%00000010
tax
noz stx pr
.bend
deccont lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd adc 172,x
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc cmd+1
dec xb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "adca"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,327 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)alrb"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta da
sta dr
sta cmd+1
lda pb
pha
plp
lda ab
and db
lsr a
sta ar
php
pla
sta pr
lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $4b
.byte 0
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "arrb"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,346 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)ancb"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
lda #$0b
sta cmd
next lda db
sta da
sta dr
sta cmd+1
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000001
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte 0
.byte 0
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
lda #$2b
cmp cmd
beq end
sta cmd
jmp next
end
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "lasay"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,336 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)anda"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta da
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "andax"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,345 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)andax"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta xb
next lda db
sta da
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and da,x
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda xb
bne nodec
dec cmd+2
nodec dec xb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "anday"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,345 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)anday"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta yb
next lda db
sta da
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and da,y
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda yb
bne nodec
dec cmd+2
nodec dec yb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "andix"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,337 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)andb"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta da
sta dr
sta cmd+1
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and #0
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "andz"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,344 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)andix"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta xb
lda #<da
sta 172
lda #>da
sta 173
next lda db
sta da
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and (172,x)
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
dec xb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "andiy"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,349 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)andiy"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta yb
lda #<da
sta 172
lda #>da
sta 173
next lda db
sta da
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and (172),y
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc 172
bne noinc
inc 173
noinc lda yb
bne nodec
dec 173
nodec dec yb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "orab"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,338 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)andz"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta 172
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "andzx"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,342 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)andzx"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
sta xb
next lda db
sta 172
sta dr
eor #$ff
sta cmdr+1
lda ab
eor #$ff
cmdr ora #0
eor #$ff
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
nozero lda ar
bpl noneg
txa
ora #%10000000
tax
noneg stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd and 172,x
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc cmd+1
dec xb
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "anda"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,341 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)aneb"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta xb
next lda db
sta da
sta dr
sta cmd+1
lda ab
ora #$ee
and xb
and db
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111101
ldx ar
bne nozero
ora #%00000010
nozero
ldx ar
bpl nominus
ora #%10000000
nominus
sta pr
lda sb
sta sr
waitborder
lda $d011
bmi border
lda $d012
cmp #40
bcs waitborder
border
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $8b
.byte 0
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc ab
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda xb
adc #17
sta xb
bcc jmpnext
lda #0
sta xb
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "lxab"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,409 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)arrb"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta da
sta dr
sta cmd+1
lda #%00001000
bit pb
bne decimal
lda pb
lsr a
lda ab
and db
ror a
sta ar
lda pb
ora #%00110000
and #%00111100
ldx ar
bne nozero
ora #%00000010
nozero
ldx ar
bpl nominus
ora #%10000000
nominus
tax
lda ar
and #%01000000
beq nocarry
inx
nocarry
lda ar
and #%01100000
beq noover
cmp #%01100000
beq noover
txa
ora #%01000000
tax
noover
stx pr
jmp nodecimal
decimal
lda pb
lsr a
lda ab
and db
sta aa
ror a
sta ar
lda pb
ora #%00110000
and #%00111100
ldx ar
bne dnozero
ora #%00000010
dnozero
ldx ar
bpl dnominus
ora #%10000000
dnominus
tax
lda ar
eor aa
and #%01000000
beq dnoover
txa
ora #%01000000
tax
dnoover
lda aa
and #$0f
cmp #$05
bcc noadjustlow
lda ar
and #$f0
sta andlow+1
lda ar
clc
adc #$06
and #$0f
andlow ora #$11
sta ar
noadjustlow
lda aa
and #$f0
cmp #$50
bcc noadjusthigh
inx
lda ar
clc
adc #$60
sta ar
noadjusthigh
stx pr
nodecimal
lda xb
sta xr
lda yb
sta yr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $6b
.byte 0
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "aneb"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,325 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asla"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
next lda db
sta da
sta dr
asl dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda dr
cmp #0
bne nozero
txa
ora #%00000010
tax
lda dr
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd asl da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "aslax"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,334 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)aslax"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta xb
next lda db
sta da
sta dr
asl dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda dr
cmp #0
bne nozero
txa
ora #%00000010
tax
lda dr
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd asl da,x
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda xb
bne nodec
dec cmd+2
nodec dec xb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "lsrn"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,326 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asln"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta ab
next lda db
sta da
sta dr
lda ab
sta aa
sta ar
asl ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda ab
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd asl a
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc ab
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "aslz"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,327 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)aslz"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
next lda db
sta 172
sta dr
asl dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda dr
cmp #0
bne nozero
txa
ora #%00000010
tax
lda dr
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd asl 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "aslzx"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,331 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)aslzx"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta xb
next lda db
sta 172
sta dr
asl dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda dr
cmp #0
bne nozero
txa
ora #%00000010
tax
lda dr
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd asl 172,x
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc cmd+1
dec xb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asla"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,326 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asoa"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
next lda db
sta da
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $0f
.word da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asoax"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,335 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asoax"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta xb
next lda db
sta da
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $1f
.word da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda xb
bne nodec
dec cmd+2
nodec dec xb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asoay"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,335 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asoay"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta yb
next lda db
sta da
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $1b
.word da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
bne noinc
inc cmd+2
noinc lda yb
bne nodec
dec cmd+2
nodec dec yb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asoix"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,334 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asoix"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta xb
lda #<da
sta 172
lda #>da
sta 173
next lda db
sta da
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $03
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc cmd+1
dec xb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asoiy"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,340 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asoiy"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta yb
lda #<da
sta 172
lda #>da
sta 173
next lda db
sta da
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $13
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc 172
bne noinc
inc 173
noinc lda yb
bne nodec
dec 173
nodec dec yb
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "rlaz"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,328 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asoz"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
next lda db
sta 172
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $07
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asozx"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,333 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)asozx"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta xb
next lda db
sta 172
asl a
sta dr
ora ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%01111100
tax
lda ar
cmp #0
bne nozero
txa
ora #%00000010
tax
lda ar
nozero asl a
bcc noneg
txa
ora #%10000000
tax
noneg lda db
bpl nocarry
txa
ora #%00000001
tax
nocarry stx pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $17
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc xb
dec cmd+1
inc db
bne jmpnext
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "asoa"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,309 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)axsa"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta ab
sta xb
next lda db
sta da
lda ab
sta ar
and xb
sta dr
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $8f
.word da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc ab
bne jmpnext
inc xb
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "axsix"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,314 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)axsix"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta ab
sta xb
lda #<da
sta 172
lda #>da
sta 173
next lda db
sta da
lda ab
sta ar
and xb
sta dr
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $83
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
inc ab
bne jmpnext
inc xb
dec cmd+1
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "alrb"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,311 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)axsz"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta ab
sta xb
next lda db
sta 172
lda ab
sta ar
and xb
sta dr
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $87
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc ab
bne jmpnext
inc xb
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "axszy"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,315 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)axszy"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta ab
sta xb
sta yb
next lda db
sta 172
lda ab
sta ar
and xb
sta dr
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd .byte $97
.byte 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
inc yb
dec cmd+1
inc ab
bne jmpnext
inc xb
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "axsa"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bccr"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%00000000
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
sec
branch bcc berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bvsr"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bcsr"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%00000001
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
clc
branch bcs berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bccr"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)beqr"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%00000010
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
lda #1
branch beq berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bner"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,331 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bita"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%00111101
tax
lda ab
and db
bne nozero
txa
ora #%00000010
tax
nozero lda db
and #%11000000
sta l0+1
txa
l0 ora #0
sta pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd bit da
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "brkn"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,333 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bitz"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
lda #0
sta db
sta ab
next lda db
sta 172
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
and #%00111101
tax
lda ab
and db
bne nozero
txa
ora #%00000010
tax
nozero lda db
and #%11000000
sta l0+1
txa
l0 ora #0
sta pr
lda sb
sta sr
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd bit 172
php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda 172
sta da
jsr check
clc
lda db
adc #17
sta db
bcc jmpnext
lda #0
sta db
clc
lda ab
adc #17
sta ab
bcc jmpnext
lda #0
sta ab
inc pb
beq nonext
jmpnext jmp next
nonext
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wait jsr $ffe4
beq wait
jmp $8000
load jsr print
name .text "bita"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check
.block
lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
.bend
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bmir"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%10000000
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
lda #$7f
branch bmi berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bplr"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bner"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%00000000
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
lda #0
branch bne berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bmir"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bplr"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%00000000
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
lda #$80
branch bpl berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bcsr"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,5 @@
branchwrap.asm

View File

@ -0,0 +1,374 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)brkn"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #0
sta pb
tsx
stx sb
tsx
stx saves+1
ldx #0
save lda $0100,x
sta $1000,x
inx
bne save
lda #0
fill sta $1100,x
inx
bne fill
lda #<break
sta $fffe
lda #>break
sta $ffff
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110100
sta pr
lda sb
sec
sbc #3
sta sr
lda #127
sta $dc0d
lda $dc0d
lda #$30
sta 1
ldx sb
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break php
cld
sta aa
stx xa
sty ya
pla
sta pa
tsx
stx sa
lda #$37
sta 1
lda #129
sta $dc0d
jsr check
tsx
lda pb
ora #%00110000
inx
cmp $0100,x
bne ste
clc
lda cmd+1
ldy cmd+2
adc #2
bcc noinc
iny
noinc inx
cmp $0100,x
bne ste
inx
tya
cmp $0100,x
beq stok
ste jsr print
.byte 13
.text "wrong data on stack"
.byte 13,0
jsr wait
stok
inc cmd+1
dec sb
inc pb
beq nonext
jmpnext jmp next
nonext
saves ldx #0
txs
ldx #0
restore lda $1000,x
sta $0100,x
inx
bne restore
jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
load jsr print
name .text "rtin"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
ldx saves+1
txs
ldx #0
restore2 lda $1000,x
sta $0100,x
inx
bne restore2
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,363 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bvcr"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%00000000
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
lda #$40
adc #$40
branch bvc berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "nopn"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,362 @@
*= $0801
.byte $4c,$16,$08,$00,$97,$32
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$30,$00,$00,$00,$a9
.byte $01,$85,$02
jsr print
.byte 13
.text "(up)bvsr"
.byte 0
lda #%00011011
sta db
lda #%11000110
sta ab
lda #%10110001
sta xb
lda #%01101100
sta yb
lda #%01000000
sta pb
tsx
stx sb
lda #0
sta db
lda #<break
sta $0316
lda #>break
sta $0317
ldx #0
txa
fill sta $1082,x
sta $1182,x
inx
bne fill
next lda db
sta da
sta dr
lda ab
sta ar
lda xb
sta xr
lda yb
sta yr
lda pb
ora #%00110000
sta pr
ldx cmd+1
lda branch
sta $1100,x
lda db
sta $1101,x
ldx sb
stx sr
txs
lda pb
pha
lda ab
ldx xb
ldy yb
plp
cmd jmp $1100
break pla
sta ya
pla
sta xa
pla
sta aa
pla
sta pa
pla
sta al+1
pla
sta ah+1
tsx
stx sa
clc
lda cmd+1
ldy cmd+2
adc #4
bcc noinc
iny
noinc bit db
bpl pos
dey
pos clc
adc db
bcc al
iny
al cmp #0
bne err
ah cpy #0
beq noerr
err jsr print
.byte 13
.text "wrong jump address"
.byte 13,0
jsr wait
noerr jsr check
inc db
lda db
cmp #$fe
bne jmpnext
lda #0
sta db
ldx cmd+1
sta $1100,x
inc cmd+1
beq nonext
jmpnext jmp next
nonext
clv
branch bvs berr
ookk jsr print
.text " - ok"
.byte 13,0
lda 2
beq load
wt jsr $ffe4
beq wt
jmp $8000
berr jsr print
.byte 13
.text "no jump expected"
.byte 13,0
jsr wait
jmp ookk
load jsr print
name .text "bvcr"
namelen = *-name
.byte 0
lda #0
sta $0a
sta $b9
lda #namelen
sta $b7
lda #<name
sta $bb
lda #>name
sta $bc
pla
pla
jmp $e16f
db .byte 0
ab .byte 0
xb .byte 0
yb .byte 0
pb .byte 0
sb .byte 0
da .byte 0
aa .byte 0
xa .byte 0
ya .byte 0
pa .byte 0
sa .byte 0
dr .byte 0
ar .byte 0
xr .byte 0
yr .byte 0
pr .byte 0
sr .byte 0
check lda da
cmp dr
bne error
lda aa
cmp ar
bne error
lda xa
cmp xr
bne error
lda ya
cmp yr
bne error
lda pa
cmp pr
bne error
lda sa
cmp sr
bne error
rts
error jsr print
.byte 13
.null "before "
ldx #<db
ldy #>db
jsr showregs
jsr print
.byte 13
.null "after "
ldx #<da
ldy #>da
jsr showregs
jsr print
.byte 13
.null "right "
ldx #<dr
ldy #>dr
jsr showregs
lda #13
jsr $ffd2
wait jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda 2
beq basic
jmp $8000
basic jmp ($a002)
showregs stx 172
sty 173
ldy #0
lda (172),y
jsr hexb
lda #32
jsr $ffd2
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
jsr hexb
lda #32
jsr $ffd2
iny
lda (172),y
ldx #"n"
asl a
bcc ok7
ldx #"N"
ok7 pha
txa
jsr $ffd2
pla
ldx #"v"
asl a
bcc ok6
ldx #"V"
ok6 pha
txa
jsr $ffd2
pla
ldx #"0"
asl a
bcc ok5
ldx #"1"
ok5 pha
txa
jsr $ffd2
pla
ldx #"b"
asl a
bcc ok4
ldx #"B"
ok4 pha
txa
jsr $ffd2
pla
ldx #"d"
asl a
bcc ok3
ldx #"D"
ok3 pha
txa
jsr $ffd2
pla
ldx #"i"
asl a
bcc ok2
ldx #"I"
ok2 pha
txa
jsr $ffd2
pla
ldx #"z"
asl a
bcc ok1
ldx #"Z"
ok1 pha
txa
jsr $ffd2
pla
ldx #"c"
asl a
bcc ok0
ldx #"C"
ok0 pha
txa
jsr $ffd2
pla
lda #32
jsr $ffd2
iny
lda (172),y
hexb pha
lsr a
lsr a
lsr a
lsr a
jsr hexn
pla
and #$0f
hexn ora #$30
cmp #$3a
bcc hexn0
adc #6
hexn0 jmp $ffd2
print pla
.block
sta print0+1
pla
sta print0+2
ldx #1
print0 lda !*,x
beq print1
jsr $ffd2
inx
bne print0
print1 sec
txa
adc print0+1
sta print2+1
lda #0
adc print0+2
sta print2+2
print2 jmp !*
.bend

View File

@ -0,0 +1,531 @@
;---------------------------------------
;cia1pb6.asm - this file is part
;of the C64 Emulator Test Suite
;public domain, no copyright
*= $0801
.byte $4c,$14,$08,$00,$97
turboass = 780
.text "780"
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$33,$00,$00,$00
.block
lda #1
sta turboass
ldx #0
stx $d3
lda thisname
printthis
jsr $ffd2
inx
lda thisname,x
bne printthis
jsr main
lda #$37
sta 1
lda #$2f
sta 0
jsr $fd15
jsr $fda3
jsr print
.text " - ok"
.byte 13,0
lda turboass
beq loadnext
jsr waitkey
jmp $8000
.bend
loadnext
.block
ldx #$f8
txs
lda nextname
cmp #"-"
bne notempty
jmp $a474
notempty
ldx #0
printnext
jsr $ffd2
inx
lda nextname,x
bne printnext
lda #0
sta $0a
sta $b9
stx $b7
lda #<nextname
sta $bb
lda #>nextname
sta $bc
jmp $e16f
.bend
;---------------------------------------
;print text which immediately follows
;the JSR and return to address after 0
print
.block
pla
sta next+1
pla
sta next+2
ldx #1
next
lda $1111,x
beq end
jsr $ffd2
inx
bne next
end
sec
txa
adc next+1
sta return+1
lda #0
adc next+2
sta return+2
return
jmp $1111
.bend
;---------------------------------------
;print hex byte
printhb
.block
pha
lsr a
lsr a
lsr a
lsr a
jsr printhn
pla
and #$0f
printhn
ora #$30
cmp #$3a
bcc noletter
adc #6
noletter
jmp $ffd2
.bend
;---------------------------------------
;wait until raster line is in border
;to prevent getting disturbed by DMAs
waitborder
.block
lda $d011
bmi ok
wait
lda $d012
cmp #30
bcs wait
ok
rts
.bend
;---------------------------------------
;wait for a key and check for STOP
waitkey
.block
jsr $fd15
jsr $fda3
cli
wait
jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda turboass
beq load
jmp $8000
load
jsr print
.byte 13
.text "break"
.byte 13,0
jmp loadnext
.bend
;---------------------------------------
thisname .null "cia1pb6"
nextname .null "cia1pb7"
main
;---------------------------------------
;old cra 0 start
; cra 1 pb6out
; cra 2 pb6toggle
;new cra 0 start
; cra 1 pb6out
; cra 2 pb6toggle
; cra 4 force load
.block
jmp start
i .byte 0
old .byte 0
new .byte 0
or .byte 0
right .text "----------------"
.text "0000000000000000"
.text "----------------"
.text "1111111111111111"
.text "----------------"
.text "0000000000000000"
.text "----------------"
.text "1111111111111111"
start
lda #0
sta i
loop
lda #$40
sta $dc03
lda #0
sta $dc01
sta $dc0e
sta $dc0f
lda #127
sta $dc0d
bit $dc0d
lda #$ff
sta $dc04
sta $dc05
lda i
and #%00000111
sta $dc0e
sta old
lda i
lsr a
lsr a
pha
and #%00010000
sta or
pla
lsr a
and #%00000111
ora or
sta $dc0e
sta new
lda $dc01
eor #$40
sta $dc01
cmp $dc01
beq minus
eor #$40
asl a
asl a
lda #"0"/2
rol a
jmp nominus
minus
lda #"-"
nominus
ldx i
cmp right,x
beq ok
pha
jsr print
.byte 13
.text "old new pb6 "
.byte 0
lda old
jsr printhb
lda #32
jsr $ffd2
lda new
jsr printhb
lda #32
jsr $ffd2
pla
jsr $ffd2
jsr waitkey
ok
inc i
bmi end
jmp loop
end
.bend
;---------------------------------------
;toggle pb6, cra one shot, start timer
;-> pb6 must be high
;wait until cra has stopped
;-> pb6 must be low
;write cra, write ta low/high, force
;load, pb6on, pb6toggle
;-> pb6 must remain low
;start
;-> pb6 must go high
.block
lda #0
sta $dc0e
ldx #100
stx $dc04
sta $dc05
sei
jsr waitborder
lda #$0f
sta $dc0e
lda #$40
bit $dc01
bne ok1
jsr print
.byte 13
.null "pb6 is not high"
jsr waitkey
ok1
lda #$01
wait
bit $dc0e
bne wait
lda #$40
bit $dc01
beq ok2
jsr print
.byte 13
.null "pb6 is not low"
jsr waitkey
ok2
lda #$0e
sta $dc0e
lda #$40
bit $dc01
beq ok3
jsr print
.byte 13
.text "writing cra may "
.text "not set pb6 high"
.byte 0
jsr waitkey
ok3
lda #100
sta $dc04
lda #$40
bit $dc01
beq ok4
jsr print
.byte 13
.text "writing ta low may "
.text "not set pb6 high"
.byte 0
jsr waitkey
ok4
lda #0
sta $dc05
lda #$40
bit $dc01
beq ok5
jsr print
.byte 13
.text "writing ta high may "
.text "not set pb6 high"
.byte 0
jsr waitkey
ok5
lda #$1e
sta $dc0e
lda #$40
bit $dc01
beq ok6
jsr print
.byte 13
.text "force load may "
.text "not set pb6 high"
.byte 0
jsr waitkey
ok6
lda #%00001010
sta $dc0e
lda #%00001110
sta $dc0e
lda #$40
bit $dc01
beq ok7
jsr print
.byte 13
.text "switching toggle "
.text "may not set pb6 high"
.byte 0
jsr waitkey
ok7
lda #%00001100
sta $dc0e
lda #%00001110
sta $dc0e
lda #$40
bit $dc01
beq ok8
jsr print
.byte 13
.text "switching pb6on "
.text "may not set pb6 high"
.byte 0
jsr waitkey
ok8
sei
jsr waitborder
lda #%00000111
sta $dc0e
lda #$40
bit $dc01
bne ok9
jsr print
.byte 13
.text "start must set "
.text "pb6 high"
.byte 0
jsr waitkey
ok9
lda #$40
ldx #0
waitlow0
dex
beq timeout
bit $dc01
bne waitlow0
waithigh0
dex
beq timeout
bit $dc01
beq waithigh0
waitlow1
dex
beq timeout
bit $dc01
bne waitlow1
waithigh1
dex
beq timeout
bit $dc01
beq waithigh1
jmp ok
timeout
jsr print
.byte 13
.null "pb6 toggle timed out"
jsr waitkey
ok
.bend
;---------------------------------------
;cra pb6on/toggle 4 combinations
;wait until underflow
;set both pb6on and toggle
;-> pb6 must be independent from
; pb6on/toggle state at underflow
.block
jmp start
i .byte 0
start
lda #3
sta i
loop
lda #0
sta $dc0e
lda #15
sta $dc04
lda #0
sta $dc05
sei
jsr waitborder
lda i
sec
rol a
sta $dc0e
ldx #$07
stx $dc0e
ldy $dc01
sta $dc0e
ldx #$07
stx $dc0e
lda $dc01
and #$40
bne error
tya
and #$40
bne ok
error
jsr print
.byte 13
.text "toggle state is not "
.null "independent "
lda i
jsr printhb
jsr waitkey
ok
dec i
bpl loop
.bend
;---------------------------------------
;check pb6 timing
.block
jmp start
settab .byte 7,7,7,7,7,7
.byte 3,3,3,3,3,3,3,3
loadtab .byte 7,6,3,2,1,0
.byte 7,6,5,4,3,2,1,0
comptab .byte 1,0,0,1,0,0
.byte 0,1,0,0,0,0,0,1
i .byte 0
start
lda #loadtab-settab-1
sta i
loop
lda #0
sta $dc0e
ldx i
lda loadtab,x
sta $dc04
lda #0
sta $dc05
sei
jsr waitborder
ldx i
lda settab,x
sta $dc0e
nop
nop
lda $dc01
asl a
asl a
lda #0
rol a
cmp comptab,x
beq ok
jsr print
.byte 13
.null "timing error index "
lda i
jsr printhb
jsr waitkey
ok
dec i
bpl loop
.bend
;---------------------------------------
rts

View File

@ -0,0 +1,529 @@
;---------------------------------------
;cia1pb7.asm - this file is part
;of the C64 Emulator Test Suite
;public domain, no copyright
*= $0801
.byte $4c,$14,$08,$00,$97
turboass = 780
.text "780"
.byte $2c,$30,$3a,$9e,$32,$30
.byte $37,$33,$00,$00,$00
.block
lda #1
sta turboass
ldx #0
stx $d3
lda thisname
printthis
jsr $ffd2
inx
lda thisname,x
bne printthis
jsr main
lda #$37
sta 1
lda #$2f
sta 0
jsr $fd15
jsr $fda3
jsr print
.text " - ok"
.byte 13,0
lda turboass
beq loadnext
jsr waitkey
jmp $8000
.bend
loadnext
.block
ldx #$f8
txs
lda nextname
cmp #"-"
bne notempty
jmp $a474
notempty
ldx #0
printnext
jsr $ffd2
inx
lda nextname,x
bne printnext
lda #0
sta $0a
sta $b9
stx $b7
lda #<nextname
sta $bb
lda #>nextname
sta $bc
jmp $e16f
.bend
;---------------------------------------
;print text which immediately follows
;the JSR and return to address after 0
print
.block
pla
sta next+1
pla
sta next+2
ldx #1
next
lda $1111,x
beq end
jsr $ffd2
inx
bne next
end
sec
txa
adc next+1
sta return+1
lda #0
adc next+2
sta return+2
return
jmp $1111
.bend
;---------------------------------------
;print hex byte
printhb
.block
pha
lsr a
lsr a
lsr a
lsr a
jsr printhn
pla
and #$0f
printhn
ora #$30
cmp #$3a
bcc noletter
adc #6
noletter
jmp $ffd2
.bend
;---------------------------------------
;wait until raster line is in border
;to prevent getting disturbed by DMAs
waitborder
.block
lda $d011
bmi ok
wait
lda $d012
cmp #30
bcs wait
ok
rts
.bend
;---------------------------------------
;wait for a key and check for STOP
waitkey
.block
jsr $fd15
jsr $fda3
cli
wait
jsr $ffe4
beq wait
cmp #3
beq stop
rts
stop
lda turboass
beq load
jmp $8000
load
jsr print
.byte 13
.text "break"
.byte 13,0
jmp loadnext
.bend
;---------------------------------------
thisname .null "cia1pb7"
nextname .null "cia2pb6"
main
;---------------------------------------
;old crb 0 start
; crb 1 pb7out
; crb 2 pb7toggle
;new crb 0 start
; crb 1 pb7out
; crb 2 pb7toggle
; crb 4 force load
.block
jmp start
i .byte 0
old .byte 0
new .byte 0
or .byte 0
right .text "----------------"
.text "0000000000000000"
.text "----------------"
.text "1111111111111111"
.text "----------------"
.text "0000000000000000"
.text "----------------"
.text "1111111111111111"
start
lda #0
sta i
loop
lda #$80
sta $dc03
lda #0
sta $dc01
sta $dc0e
sta $dc0f
lda #127
sta $dc0d
bit $dc0d
lda #$ff
sta $dc06
sta $dc07
lda i
and #%00000111
sta $dc0f
sta old
lda i
lsr a
lsr a
pha
and #%00010000
sta or
pla
lsr a
and #%00000111
ora or
sta $dc0f
sta new
lda $dc01
eor #$80
sta $dc01
cmp $dc01
beq minus
eor #$80
asl a
lda #"0"/2
rol a
jmp nominus
minus
lda #"-"
nominus
ldx i
cmp right,x
beq ok
pha
jsr print
.byte 13
.text "old new pb7 "
.byte 0
lda old
jsr printhb
lda #32
jsr $ffd2
lda new
jsr printhb
lda #32
jsr $ffd2
pla
jsr $ffd2
jsr waitkey
ok
inc i
bmi end
jmp loop
end
.bend
;---------------------------------------
;toggle pb7, crb one shot, start timer
;-> pb7 must be high
;wait until crb has stopped
;-> pb7 must be low
;write crb, write ta low/high, force
;load, pb7on, pb7toggle
;-> pb7 must remain low
;start
;-> pb7 must go high
.block
lda #0
sta $dc0f
ldx #100
stx $dc06
sta $dc07
sei
jsr waitborder
lda #$0f
sta $dc0f
lda #$80
bit $dc01
bne ok1
jsr print
.byte 13
.null "pb7 is not high"
jsr waitkey
ok1
lda #$01
wait
bit $dc0f
bne wait
lda #$80
bit $dc01
beq ok2
jsr print
.byte 13
.null "pb7 is not low"
jsr waitkey
ok2
lda #$0e
sta $dc0f
lda #$80
bit $dc01
beq ok3
jsr print
.byte 13
.text "writing crb may "
.text "not set pb7 high"
.byte 0
jsr waitkey
ok3
lda #100
sta $dc06
lda #$80
bit $dc01
beq ok4
jsr print
.byte 13
.text "writing ta low may "
.text "not set pb7 high"
.byte 0
jsr waitkey
ok4
lda #0
sta $dc05
lda #$80
bit $dc01
beq ok5
jsr print
.byte 13
.text "writing ta high may "
.text "not set pb7 high"
.byte 0
jsr waitkey
ok5
lda #$1e
sta $dc0f
lda #$80
bit $dc01
beq ok6
jsr print
.byte 13
.text "force load may "
.text "not set pb7 high"
.byte 0
jsr waitkey
ok6
lda #%00001010
sta $dc0f
lda #%00001110
sta $dc0f
lda #$80
bit $dc01
beq ok7
jsr print
.byte 13
.text "switching toggle "
.text "may not set pb7 high"
.byte 0
jsr waitkey
ok7
lda #%00001100
sta $dc0f
lda #%00001110
sta $dc0f
lda #$80
bit $dc01
beq ok8
jsr print
.byte 13
.text "switching pb7on "
.text "may not set pb7 high"
.byte 0
jsr waitkey
ok8
sei
jsr waitborder
lda #%00000111
sta $dc0f
lda #$80
bit $dc01
bne ok9
jsr print
.byte 13
.text "start must set "
.text "pb7 high"
.byte 0
jsr waitkey
ok9
lda #$80
ldx #0
waitlow0
dex
beq timeout
bit $dc01
bne waitlow0
waithigh0
dex
beq timeout
bit $dc01
beq waithigh0
waitlow1
dex
beq timeout
bit $dc01
bne waitlow1
waithigh1
dex
beq timeout
bit $dc01
beq waithigh1
jmp ok
timeout
jsr print
.byte 13
.null "pb7 toggle timed out"
jsr waitkey
ok
.bend
;---------------------------------------
;crb pb7on/toggle 4 combinations
;wait until underflow
;set both pb7on and toggle
;-> pb7 must be independent from
; pb7on/toggle state at underflow
.block
jmp start
i .byte 0
start
lda #3
sta i
loop
lda #0
sta $dc0f
lda #15
sta $dc06
lda #0
sta $dc07
sei
jsr waitborder
lda i
sec
rol a
sta $dc0f
ldx #$07
stx $dc0f
ldy $dc01
sta $dc0f
ldx #$07
stx $dc0f
lda $dc01
and #$80
bne error
tya
and #$80
bne ok
error
jsr print
.byte 13
.text "toggle state is not "
.null "independent "
lda i
jsr printhb
jsr waitkey
ok
dec i
bpl loop
.bend
;---------------------------------------
;check pb7 timing
.block
jmp start
settab .byte 7,7,7,7,7,7
.byte 3,3,3,3,3,3,3,3
loadtab .byte 7,6,3,2,1,0
.byte 7,6,5,4,3,2,1,0
comptab .byte 1,0,0,1,0,0
.byte 0,1,0,0,0,0,0,1
i .byte 0
start
lda #loadtab-settab-1
sta i
loop
lda #0
sta $dc0f
ldx i
lda loadtab,x
sta $dc06
lda #0
sta $dc07
sei
jsr waitborder
ldx i
lda settab,x
sta $dc0f
nop
nop
lda $dc01
asl a
lda #0
rol a
cmp comptab,x
beq ok
jsr print
.byte 13
.null "timing error index "
lda i
jsr printhb
jsr waitkey
ok
dec i
bpl loop
.bend
;---------------------------------------
rts

Some files were not shown because too many files have changed in this diff Show More