Merge pull request #129 from greg-king5/cbmdir
Update 2 CBM directory functions.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Ullrich von Bassewitz, 2012-06-03. Based on code by Groepaz.
|
** 2012-06-03, Ullrich von Bassewitz. Based on code by Groepaz.
|
||||||
|
** 2014-07-16, Greg King
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -15,8 +16,10 @@ void __fastcall__ seekdir (register DIR* dir, long offs)
|
|||||||
unsigned char count;
|
unsigned char count;
|
||||||
unsigned char buf[128];
|
unsigned char buf[128];
|
||||||
|
|
||||||
/* Make sure we have a reasonable value for offs */
|
/* Make sure that we have a reasonable value for offs. We reject
|
||||||
if (offs > 0x1000) {
|
** negative numbers by converting them to (very high) unsigned values.
|
||||||
|
*/
|
||||||
|
if ((unsigned long)offs > 0x1000uL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -32,15 +35,15 @@ void __fastcall__ seekdir (register DIR* dir, long offs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Skip until we've reached the target offset in the directory */
|
/* Skip until we've reached the target offset in the directory */
|
||||||
o = dir->off = offs;
|
o = dir->off = (unsigned)offs;
|
||||||
while (o) {
|
while (o) {
|
||||||
|
|
||||||
/* Determine size of next chunk to read */
|
/* Determine size of next chunk to read */
|
||||||
if (o > sizeof (buf)) {
|
if (o > sizeof (buf)) {
|
||||||
count = sizeof (buf);
|
count = sizeof (buf);
|
||||||
o -= sizeof (buf);
|
o -= sizeof (buf);
|
||||||
} else {
|
} else {
|
||||||
count = offs;
|
count = (unsigned char)o;
|
||||||
o = 0;
|
o = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
;
|
;
|
||||||
; Oliver Schmidt, 2012-10-16
|
; 2012-10-16, Oliver Schmidt
|
||||||
|
; 2014-07-16, Greg King
|
||||||
;
|
;
|
||||||
; unsigned char __fastcall__ _syschdir (const char* name);
|
; unsigned char __fastcall__ _syschdir (const char* name);
|
||||||
;
|
;
|
||||||
@@ -39,18 +40,14 @@
|
|||||||
|
|
||||||
; Multiply first digit by 10
|
; Multiply first digit by 10
|
||||||
|
|
||||||
ldx #8
|
txa
|
||||||
@L0: asl
|
asl a ; * 2
|
||||||
asl tmp1
|
asl a ; * 4, carry cleared
|
||||||
bcc @L1
|
adc tmp1 ; * 5
|
||||||
clc
|
asl a ; * 10, carry cleared
|
||||||
adc #10
|
|
||||||
@L1: dex
|
|
||||||
bne @L0
|
|
||||||
|
|
||||||
; Add second digit to product
|
; Add second digit to product
|
||||||
|
|
||||||
clc
|
|
||||||
adc tmp2
|
adc tmp2
|
||||||
tax
|
tax
|
||||||
|
|
||||||
@@ -80,7 +77,8 @@ done: rts
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
;--------------------------------------------------------------------------
|
;--------------------------------------------------------------------------
|
||||||
; getdigit
|
; getdigit -- Converts PetSCII to binary.
|
||||||
|
; Sets carry if the character is outside of '0'-'9'.
|
||||||
|
|
||||||
.proc getdigit
|
.proc getdigit
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user