~rabbits/left

9840152e0154cd8fc065847224ab9bddc589caf2 — Devine Lu Linvega 23 days ago e2b3d77
Added binary file open
2 files changed, 58 insertions(+), 5 deletions(-)

M build.sh
M src/left.tal
M build.sh => build.sh +4 -4
@@ 9,7 9,7 @@ SRC="src/left.tal"
DST="bin/left.rom"

CPY="$HOME/roms"
ARG="src/left.tal"
ARG="etc/ss10x10.chr"

APPID="hundredrabbits/left:uxn"



@@ 19,7 19,7 @@ mkdir bin

if [[ "$*" == *"--lint"* ]]
then
  echo ">> Linting $SRC"
	echo ">> Linting $SRC"
	$LIN $SRC
fi



@@ 28,13 28,13 @@ $ASM $SRC $DST

if [[ "$*" == *"--save"* ]]
then
  echo ">> Saving $DST"
	echo ">> Saving $DST"
	cp $DST $CPY
fi

if [[ "$*" == *"--push"* ]]
then
  echo ">> Pushing $DST"
	echo ">> Pushing $DST"
	$APP $DST $APPID
fi


M src/left.tal => src/left.tal +54 -1
@@ 72,10 72,11 @@ BRK

@manifest

	05 "Left $1
	06 "Left $1
		01 "n =file-new "New $1
		01 "r =trap "Rename $1
		01 "o =file-open "Open $1
		01 "p =file-open-binary "Open 20 "Binary $1
		01 "s =file-save "Save $1
		01 "q =exit "Exit $1
	08 "Edit $1


@@ 389,6 390,17 @@ JMP2r

JMP2r

@put-byte ( byte -- )

	DUP #04 SFT put-byte/h &h
	#0f AND DUP #09 GTH #27 MUL ADD #30 ADD

@put-char ( char -- )

	get-eof STA .textarea/length LDZ2k INC2 ROT STZ2

JMP2r

@count-lines ( -- line* )

	LITr -scroll/y LDZ2r


@@ 1222,6 1234,8 @@ JMP2r

@file-open ( -- )

	file-is-bin ?file-open-binary

	;text #ffff OVR2 SUB2 mclr
	;filepath .File/name DEO2
	#fff0 ;text SUB2 .File/length DEO2


@@ 1237,6 1251,31 @@ JMP2r

!draw-state

@file-open-binary ( -- )

	#0000 .textarea/length STZ2

	;filepath .File/name DEO2
	#0001 .File/length DEO2
	#0000
	&s
		;&b .File/read DEO2
		.File/success DEI2 #0000 EQU2 ?&end
		[ LIT &b $1 ] put-byte INC2
		( format )
		DUP #01 AND ?&no-odd
			DUP #0f AND #00 NEQ #16 MUL #0a ADD put-char &no-odd
		!&s
	&end
	POP2
	#0000 scroll-to
	#0101 .textarea STZ2
	reset-selection
	#01 draw-filepath
	#02

!draw-state

@file-save ( -- )

	edit-trim


@@ 1272,6 1311,20 @@ JMP2r
!scmp
	&tal-ext ".tal $1

@file-is-bin ( -- bool )

	;filepath .File/name DEO2
	#0001 .File/length DEO2
	&s
		;&b .File/read DEO2
		.File/success DEI2 #0000 EQU2 ?&end
		[ LIT &b $1 ] ?&no-null #01 JMP2r &no-null
		!&s
		&end
	#00

JMP2r

(
@|snarf )