Jump to content

artrag

Members
  • Content Count

    1,585
  • Joined

  • Last visited

Community Reputation

744 Excellent

3 Followers

About artrag

Profile Information

  • Gender
    Male

Recent Profile Visitors

25,600 profile views
  1. You was executing data as they were instructions. The best way to get a crash...
  2. artrag

    SGM 5th run

    No the black one
  3. artrag

    SGM 5th run

    Mine has arrived! Thanks
  4. Just a note. This line Peek(VarPtr Pow2Table(Exp)) is equivalent to Pow2Table(Exp)
  5. How fast! It works great! Probably less detail on trees would help in getting less aliasing
  6. Provided that Pandora Project is on its own way, maybe the procedure ExtractField could be a very useful tool for everyone if developed in ASM Maybe using the ASM directive and the naming convention for variables in ASM the integration with intybasic could be easy. I would try myself but I a total noob with the CP1600
  7. Yes the bottleneck is ExtractField. Its multiplications and divisions make the bit extraction too slow to be practically usable.
  8. Hi DZ, I've been testing for a while your code for extracting bit files with variable length from a bit stream, but something wasn't working as I expected. So I have done my own version of the ExtractField in the way I was expecting to be used 🙂 I've also implemented the simple encoding that we discussed. It is a pure differential encoder without run length encoding. INCLUDE "constants.bas" MODE SCREEN_FB sound 5,0 ' Ensure ECS ROMs are mapped out. OPTION EXPLICIT ON DEF FN ExtractField(Bits) = FieldLen = Bits : Gosub ExtractField DIM FieldLen,#WordAdr,#MaxWordAdr,FieldOffset,NextFieldOffset,#Field #WordAdr = varptr #bitstream(0) #MaxWordAdr = varptr #bitstream_end(0) FieldOffset = 0 DIM Idx,#Output,Cmd #Output = 7 + 32*8 ' only for test, it should be 0 Idx = 0 Do Gosub ProcessNextCommand #BACKTAB(Idx) = #Output Idx = (Idx + 1) Loop While (Idx < 240) while (1):wend ' 3 bits for commands + variable lenght filed 'FBT ==Foreground,Backgrounf,Tile '000 = nothing has changed, repeat last backtab word '100 + 3 = 6 bits if foreground color changes '010 + 4 = 7 bits if background color changes '001 + 7 = 10 bits if tile number changes '110 + 7 = 10 bits if foreground and background change '101 + 10 = 13 bits if foreground and tile number change '011 + 11 = 14 bits if background and tile number change '111 + 14 = 17 bits if everything changes Const MSK_BTAB_FG_COL = &0000000000000111 Const MSK_BTAB_BG_COL = &0011011000000000 Const MSK_BTAB_PIC = &0000100111111000 Const MSK_GRAM_FLG = &0000100000000000 #BackGround: DATA $0000 ' BG_BLACK DATA $0200 ' BG_BLUE DATA $0400 ' BG_RED DATA $0600 ' BG_TAN DATA $2000 ' BG_DARKGREEN DATA $2200 ' BG_GREEN DATA $2400 ' BG_YELLOW DATA $2600 ' BG_WHITE DATA $1000 ' BG_GREY DATA $1200 ' BG_CYAN DATA $1400 ' BG_ORANGE DATA $1600 ' BG_BROWN DATA $3000 ' BG_PINK DATA $3200 ' BG_LIGHTBLUE DATA $3400 ' BG_YELLOWGREEN DATA $3600 ' BG_PURPLE ProcessNextCommand:procedure ExtractField(3) Cmd = #Field if Cmd and 1 then gosub foreground if Cmd and 2 then gosub background if Cmd and 4 then gosub tile end foreground: procedure ExtractField(3) #Output = (#Output and (not MSK_BTAB_FG_COL)) + #Field end background: procedure ExtractField(4) #Output = (#Output and (not MSK_BTAB_BG_COL)) + #BackGround(#Field) end tile: procedure ExtractField(7) #Output = (#Output and (not MSK_BTAB_PIC)) + (#Field and &111111)*8 + (MSK_GRAM_FLG and ((#Field and &1000000)>0)) end ExtractField: procedure ' input: FieldLen = number of bits to read (from 0 to 16) ' FieldOffset,#WordAdr,#MaxWordAdr = data start and data end pointers ' output: #Field value of the FieldLen bits extracted from the stream ' local variables: NextFieldOffset SIGNED NextFieldOffset if (#WordAdr < #MaxWordAdr) then NextFieldOffset = FieldLen+FieldOffset-16 ' bit offset in the next word #Field = peek(#WordAdr) / Pow2Table(FieldOffset) if (NextFieldOffset<=0) then ' all bits within the current word #Field = (Pow2Table(FieldLen)-1) and #Field else ' you need also bits from the next word #Field = #Field + ((Pow2Table(NextFieldOffset)-1) and peek(#WordAdr+1)) * Pow2Table(16-FieldOffset) end if FieldOffset = FieldOffset + FieldLen if (FieldOffset>15) then #WordAdr = #WordAdr + 1 FieldOffset = FieldOffset and 15 end if end if end ' Table of Powers of 2 (0..15) Pow2Table: DATA $0001, $0002, $0004, $0008, $0010, $0020, $0040, $0080 DATA $0100, $0200, $0400, $0800, $1000, $2000, $4000, $8000 DATA $0000 ' used for (2^16) - 1 ' Test sequences #bitstream: ' FEDCBA9876543210 DATA &0100001100000000 DATA &0100010100000000 DATA &1000110001110000 DATA &0000000000000000 DATA &0100001100000000 DATA &0100010100000000 DATA &1000110001110000 DATA &0000000000000000 #bitstream_end: Aside from the compression ratio, the main concern is the speed of the layer in charge of extracting bits... I think there is no practical application if the code of ExtractField stays in intybasic because of the speed of multiplications and divisions needed to shift bits inside the word stream. What do you think ? Can the code be made faster? I think only an ASM implementation, using shift instructions, could make it usable.
  9. I'm sorry I return on the topic but something strange is happening with varptr... This lines do not work, as intybasic keeps telling that the expression is not constant const #max_bit_index = (VARPTR #bitstream_end(0) - VARPTR #bitstream(0)) * 16 but it is very constant as the arrays are #bitstream: DATA &1001100110011001,&1001100110011001,&1001100110011001,&1001100110011001,&1001100110011001 #bitstream_end: Moreover, I spotted that randomly, if I use the minuscule varprt, sometimes it does not compile, telling that some brackets is odd #max_bit_index = (varprt #bitstream_end(0) - varprt #bitstream(0)) * 16 It is like varprt (in minuscule) sometimes is confused by a variable name....
  10. Thanks for the elegant solution! I wasn't asking that much
  11. The idea is to have a tool able to extract n bits from the current position and to update the current position. As you know from other threads we need to read a variable number of bits from 3 to 14 bits each time.
  12. I am interested in developing (in intybasic) a general purpose subroutine able to extract a code with a given number of bits from a bitstream of words stored as DATA Something close to this: #bitstream: DATA &1001100110011001,&1001100110011001,&1001100110011001,&1001100110011001,&1001100110011001,..... read_code: procedure ' input: n number of bits to read (from 1 to 16) ' output: #code value of the n bits extracted from the stream ' local variables: #bit_index - starts from 0 and each time you read a code is incremented of n, "pointing" to the current next bit to be extracted ' local constant: #max_bit_index - used to testing against overflow, you cannot read after the end of the bitstream [do the magic] end Does anyone have such a routine already developed and tested and wants to share it?
  13. Definitely it doesn't handle correctly negative numbers... Now I've processed my data to make them fit in 8bit unsigned and it works.
  14. I suspect (say I'm almost sure) there is something wrong in DATA PACKED I've compiled the code in attach and the sequence of data DATA PACKED -1,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 DATA PACKED -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65,129 DATA PACKED -1,130, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,129, -1 DATA PACKED 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, -1, -1 Becomes in the ROM (using hex explorer) db FFh,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h db FFh,00h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,41h,81h db FFh,82h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh db 80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,80h,FFh,FFh As you may see the 3rd line ends by FFh,FFh but it should have been 81h,FFh Same, later, for DATA PACKED -1, -1,130, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1 that becomes db FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh The problem occurs on each 3rd line more or less, but I cannot see a clear pattern testpackedattributes.bas romtest.bin
×
×
  • Create New...