Skip to content

Commit

Permalink
diskio docs, remove super harmless warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Dec 5, 2024
1 parent 617ea15 commit ba8c3d1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
16 changes: 8 additions & 8 deletions codeGenCpu6502/src/prog8/codegen/cpu6502/IfElseAsmGen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal class IfElseAsmGen(private val program: PtProgram,
require(target.datatype==expr.type)
val falseLabel = asmgen.makeLabel("ifexpr_false")
val endLabel = asmgen.makeLabel("ifexpr_end")
evalConditonAndBranchWhenFalse(expr.condition, falseLabel)
evalIfExpressionConditonAndBranchWhenFalse(expr.condition, falseLabel)
when(expr.type) {
in ByteDatatypesWithBoolean -> {
asmgen.assignExpressionToRegister(expr.truevalue, RegisterOrPair.A, false)
Expand Down Expand Up @@ -93,12 +93,12 @@ internal class IfElseAsmGen(private val program: PtProgram,
}
}

private fun evalConditonAndBranchWhenFalse(condition: PtExpression, falseLabel: String) {
private fun evalIfExpressionConditonAndBranchWhenFalse(condition: PtExpression, falseLabel: String) {
if (condition is PtBinaryExpression) {
return when(condition.right.type) {
in ByteDatatypesWithBoolean -> translateIfByteConditionBranch(condition, falseLabel)
in WordDatatypes -> translateIfWordConditionBranch(condition, falseLabel)
DataType.FLOAT -> translateFloatConditionBranch(condition, falseLabel)
in ByteDatatypesWithBoolean -> translateIfExpressionByteConditionBranch(condition, falseLabel)
in WordDatatypes -> translateIfExpressionWordConditionBranch(condition, falseLabel)
DataType.FLOAT -> translateIfExpressionFloatConditionBranch(condition, falseLabel)
else -> throw AssemblyError("weird dt")
}
}
Expand Down Expand Up @@ -359,7 +359,7 @@ internal class IfElseAsmGen(private val program: PtProgram,
}
}

private fun translateIfByteConditionBranch(condition: PtBinaryExpression, falseLabel: String) {
private fun translateIfExpressionByteConditionBranch(condition: PtBinaryExpression, falseLabel: String) {
val signed = condition.left.type in SignedDatatypes
val constValue = condition.right.asConstInteger()
if(constValue==0) {
Expand Down Expand Up @@ -398,7 +398,7 @@ internal class IfElseAsmGen(private val program: PtProgram,
}
}

private fun translateIfWordConditionBranch(condition: PtBinaryExpression, falseLabel: String) {
private fun translateIfExpressionWordConditionBranch(condition: PtBinaryExpression, falseLabel: String) {
// TODO can we reuse this whole thing from IfElse ?
val constValue = condition.right.asConstInteger()
if(constValue!=null) {
Expand Down Expand Up @@ -2048,7 +2048,7 @@ _jump jmp ($asmLabel)
}
}

private fun translateFloatConditionBranch(condition: PtBinaryExpression, elseLabel: String) {
private fun translateIfExpressionFloatConditionBranch(condition: PtBinaryExpression, elseLabel: String) {
val constValue = (condition.right as? PtNumber)?.number
if(constValue==0.0) {
if (condition.operator == "==") {
Expand Down
4 changes: 2 additions & 2 deletions compiler/res/prog8lib/cx16/monogfx.p8
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ skip:
}

sub fill_scanline_left() -> bool {
; TODO maybe this could use vera auto decrement, but that would require some clever masking calculations
; TODO maybe this could use vera auto decrement, but that requires some clever masking calculations
cx16.r9s = xx
while xx >= 0 {
if pgetset()
Expand All @@ -807,7 +807,7 @@ skip:
}

sub fill_scanline_right() {
; TODO maybe this could use vera auto increment, but that would require some clever masking calculations
; TODO maybe this could use vera auto increment, but that requires some clever masking calculations
cx16.r9s = xx
while xx <= width-1 {
if pgetset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ internal class NotExpressionAndIfComparisonExprChanger(val program: Program, val
val prefix = ifElse.condition as? PrefixExpression
if(prefix?.operator=="not") {
// if not x a else b -> if x b else a
errors.info("invert condition and swap if/else blocks", ifElse.condition.position)
ifElse.condition = prefix.expression
ifElse.condition.parent = ifElse
val elsepart = ifElse.elsepart
Expand Down
22 changes: 14 additions & 8 deletions docs/source/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ Provides several routines that deal with disk drive I/O, such as:
- delete and rename files on the disk
- send arbitrary CbmDos command to disk drive

For simplicity sake, this library is designed to work on a *single* open file
for reading, and a *single* open file for writing at any time only.
If you need to load or save to more than one file at a time, you'll have
to write your own I/O routines (or supplement the ones found here)

You can set the active *disk drive number*, so it supports multiple drives, just one at a time.
It does not support reading from more than one file or writing to more than one file at a time.

Commander X16 additions:
Headerless load and save routines are available (load_raw, save_raw).
On the Commander X16 it tries to use that machine's fast Kernal loading routines if possible.
Expand All @@ -511,20 +519,18 @@ Read the `diskio source code <https://github.com/irmen/prog8/tree/master/compile
to see what's in there. (Note: slight variations for different compiler targets)

.. note::
For simplicity sake, this library is designed to work on a *single* open file
for reading, and a *single* open file for writing at any time only.
If you need to load or save to more than one file at a time, you'll have
to write your own I/O routines (or supplement the ones found here)
Opening a file using f_read() or f_read_w() doesn't set the default i/o channels to that file.
In fact, after calling routines in diskio, it resets the input and output channels to their
defaults (keyboard and screen).
If you are going to do kernal I/O calls like CHRIN/CHROUT/(M)ACPTR yourself on the files opened via diskio,
you must use reset_read_channel() or reset_write_channel() before doing so. This makes
the correct file channel active. The diskio routines themselves do this as well internally.

.. note::
If you are using the X16 emulator with HostFS, and are experiencing weird behavior with these
routines, please first try again with an SD-card image instead of HostFs.
It is possible that there are still small differences between HostFS and actual CBM DOS in the X16 emulator.

.. note::
You can set the active disk drive number, so it supports multiple drives, just one at a time.
It does not support reading from more than one file or writing to more than one file at a time.

.. attention::
Error handling is peculiar on CBM dos systems (C64, C128, cx16, PET). Read the
descriptions for the various methods in this library for details and tips.
Expand Down
1 change: 0 additions & 1 deletion examples/cx16/starszoom.p8
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
; Movement is dictated by a random accelleration, which increases the speed, which increases the radius.

; TODO extend the radius to a larger maximum (0-319 or perhaps 0-511, instead of 0-255) so that we can fill the whole screen.
; TODO do something with the colors palette: make stars darker in the distance

%import math
%import palette
Expand Down

0 comments on commit ba8c3d1

Please sign in to comment.