added capacity calculation

added a few comments to demo
This commit is contained in:
thrust26 2021-04-12 10:50:03 +02:00
parent eefc158261
commit 8a1cec8a92
2 changed files with 34 additions and 26 deletions

View File

@ -4,7 +4,6 @@
IF QR_VERSION = 1 ;{
QR_SIZE = 21 ; 21x21 QR code
QR_CAPACITY = 26
IF QR_LEVEL = 0
QR_DEGREE = 7 ; for version 1, level L QR codes
ENDIF
@ -21,7 +20,6 @@ QR_DEGREE = 17 ; for version 1, level H QR codes
IF QR_VERSION = 2
QR_SIZE = 25 ; 25x25 QR code
QR_CAPACITY = 44
IF QR_LEVEL = 0
QR_DEGREE = 10 ; for version 2, level L QR codes
ENDIF
@ -38,7 +36,6 @@ QR_DEGREE = 28 ; for version 2, level H QR codes
IF QR_VERSION = 3 ;{
QR_SIZE = 29 ; 29x29 QR code
QR_CAPACITY = 70
IF QR_LEVEL = 0
QR_DEGREE = 15 ; for version 3, level L QR codes
ENDIF
@ -52,6 +49,17 @@ QR_DEGREE = 26 ; for version 3, level M QR codes
ENDIF
ENDIF ;}
; Calculate capacity based on version
_QR_VAL SET (QR_VERSION * 16 + 128) * QR_VERSION + 64
IF QR_VERSION >= 2
_QR_NUM_ALIGN = QR_VERSION / 7 + 2
_QR_VAL SET _QR_VAL - ((25 * _QR_NUM_ALIGN - 10) * _QR_NUM_ALIGN - 55)
IF QR_VERSION >= 7
_QR_VAL SET _QR_VAL - 36
ENDIF
ENDIF
QR_CAPACITY = _QR_VAL / 8
QR_MAX_DATA = QR_CAPACITY - QR_DEGREE
QR_MODE = %0100 ; byte mode
@ -423,25 +431,18 @@ QR_TOTAL = QR_MAX_DATA + QR_DEGREE ; 44
;-----------------------------------------------------------
MAC _DRAW_FORMAT
;-----------------------------------------------------------
IF QR_SINGLE_MASK = 0
IF QR_SINGLE_MASK = 0
.idx = tmpVars
ldy #QR_FORMATS-1
.loopFormat
sty .idx
cpy #8
; IF QR_SINGLE_MASK
; lda #%10101000
; and BitMask,y
; bcc .lowFormat
; lda #%00100100
; ELSE
ldx qrPattern
lda FormatLo,x
and BitMask,y
bcc .lowFormat
lda FormatHi,x
; ENDIF
and BitMask-8,y
.lowFormat
beq .skipFormat
@ -458,7 +459,7 @@ QR_TOTAL = QR_MAX_DATA + QR_DEGREE ; 44
.skipFormat
dey
bpl .loopFormat
ENDIF
ENDIF
ENDM
; ********** The user macros start here: **********
@ -656,7 +657,7 @@ FormatHi
ENDIF
ENDIF ; /QR_SINGLE_MASK = 0
; position of the 15 type information bits
; positions of the 15 type information bits
FormatX1
.byte 0, 1, 2, 3, 4, 5, 7, 8
.byte 8, 8, 8, 8, 8, 8, 8
@ -723,7 +724,7 @@ Generator ; data in reversed order!
.byte $0d, $1c, $09, $fc
ENDIF
QR_DEGREE = . - Generator ; verify data
QR_DEGREE = . - Generator ; verify data size
ECHO "QR Code encoding data:", [. - QRCodeData]d, "bytes"
_QR_TOTAL SET _QR_TOTAL + . - QRCodeData

View File

@ -34,15 +34,17 @@
BASE_ADR = $f000
NTSC = 1
NTSC = 1 ; 0 = PAL50
; QR Code Generator Switches
QR_VERSION = 2 ; 1, 2 or 3 (TODO 1 and 3)
QR_LEVEL = 1 ; 0 (L), 1 (M), 2 (Q) and 3 (H))
QR_OVERLAP = 1 ; overlaps input and output data to save RAM (0 not tested!)
QR_SINGLE_MASK = 0 ; (-255) if 1 uses only 1 of the 8 mask pattern
QR_PADDING = 1 ; (+22) add padding bytes
; Atari 2600 specific QR settings (set to 0 for other platforms)
QR_OVERLAP = 1 ; overlaps input and output data to save RAM (defined for version 2 only!)
QR_SINGLE_MASK = 0 ; (-255) if 1 uses only 1 of the 8 mask pattern
IF QR_VERSION = 1 || QR_VERSION = 3
ECHO ""
ECHO "ERROR: Version", [QR_VERSION]d, "unsupported by demo code"
@ -148,6 +150,7 @@ CODE_LST_SIZE = . - qrCodeLst
;-----------------------------------------------------------
MAC _BLACK_FUNC
;-----------------------------------------------------------
; blacks all function/alignment and timing pattern
ldx #CODE_LST_SIZE-1
.loopBlack
lda BlackGfx,x
@ -161,6 +164,7 @@ CODE_LST_SIZE = . - qrCodeLst
;-----------------------------------------------------------
MAC _BLACK_LEFT
;-----------------------------------------------------------
; blacks all function/alignment and timing pattern of the left column
ldx #NUM_FIRST + QR_SIZE-1-8
.loopBlackLeft
lda LeftBlack+8,x
@ -172,6 +176,7 @@ CODE_LST_SIZE = . - qrCodeLst
;-----------------------------------------------------------
MAC _BLACK_MIDDLE
;-----------------------------------------------------------
; blacks all function/alignment and timing pattern of the middle column
ldx #QR_SIZE-1
.loopBlackMiddle
lda GRP1Black,x
@ -183,6 +188,7 @@ CODE_LST_SIZE = . - qrCodeLst
;-----------------------------------------------------------
MAC _BLACK_RIGHT
;-----------------------------------------------------------
; blacks all function/alignment and timing pattern of the right column
ldx #QR_SIZE
.loopBlackRight
lda GRP0RBlack-1,x
@ -264,7 +270,7 @@ DrawScreen SUBROUTINE
.enterLoop
sta .tmpFirst ; 3 = 8
.endFirst ; @70/69
ldy #2 ; 2
ldy #-2 ; 2
.loopBlock
sta WSYNC ; 3 @75/74
;---------------------------------------
@ -276,15 +282,15 @@ DrawScreen SUBROUTINE
sta GRP1 ; 3
lda grp0LLst,x ; 4
sta GRP0 ; 3
SLEEP 17-7 ;10
SLEEP 10 ;10 = 24
lda grp0RLst,x ; 4
dey ; 2 = 30
cpy #$01 ; 2
bne .isff ; 2/3
iny ; 2
cpy #1 ; 2
bcc .isZero ; 2/3
BIT_B ; 1
.isff
.isZero
dex ; 2
sta GRP0 ; 3 = 10 @48
sta GRP0 ; 3 = 16 @48
bcs .loopBlock ; 2/3
bpl .loopKernel ; 3/2=5/4
sta WSYNC
@ -572,7 +578,7 @@ _QR_TOTAL SET _QR_TOTAL + . - FunctionModulesData
.byte " QR Code Generator Demo V0.3 - (C)2021 Thomas Jentzsch "
; messages MUST not be longer than 26 bytes for version 2, level M!
; messages MUST NOT be longer than 26 bytes for version 2, level M!
; Galadriel:
MessageTbl
Message0
@ -631,4 +637,5 @@ MessagePtrHi
ECHO "----------------------------------------"
ECHO "QR Code total:", [_QR_TOTAL]d, "bytes"
ECHO ""
ECHO "QR Code Version, Level (Degree): ", [QR_VERSION]d, ",", [QR_LEVEL]d, "(", [QR_DEGREE]d, ")"
ECHO "QR Code Version", [QR_VERSION]d, ", Level (Degree)", [QR_LEVEL]d, "(", [QR_DEGREE]d, "), Capacity", [QR_CAPACITY]d, "bytes"
ECHO " -> Message Space", [QR_CAPACITY-QR_DEGREE-2]d, "bytes"