|
Post by hydrophilic on Jan 28, 2015 8:59:47 GMT
Thank you for SOURCE CODE!
Most of it looks like standard VB, except the first line "Imports System.Threading.Tasks". What version of VB compiler do use?
Also I noticed at least one of your functions has the attribute "Handles"... That is totally new to me...
Call me old school (shock!) but I don't know what that does... presumably it deals with VB 'events'. Please school us! (or at least me )
|
|
|
Post by VDC 8x2 on Jan 28, 2015 11:06:35 GMT
I am using Microsoft visual studio express 2013 for windows desktop. The imports thing invokes the multithreading functions.
It ties the functions to the windows buttons in this code.
Looking at the code, I see some optimizations I can make.
|
|
|
Post by VDC 8x2 on Jan 29, 2015 0:09:15 GMT
Have you updated your code for the lsr optimization we talked about yet?
|
|
|
Post by hydrophilic on Jan 29, 2015 7:31:56 GMT
Sadly no... I'm still working on the high-level image encoding/compression functions. Once I am satisfied it works reliably (good, but not necessarily perfectly optimal) I will dig into to the low-level "byte-code".
(Not to derail the topic, but finding a good text-mode algorithm is very challenging... with VDC bitmap you can have 2 colors per cell, but the data rate is too high for video. With VDC text-mode the data rate is good for video, but with only one color per cell [plus one global color] the encoding is a *LOT* more challenging...)
Anyway, thanks for the feedback... it seems I need to download "visual studio express 2013"
|
|
|
Post by hydrophilic on Jan 29, 2015 8:28:07 GMT
Sorry for the double-post, but I tried download from MS and got a really weird error... so I tried to contact their tech support and got yet another error...
Can you say DOUBLE FAIL? Good... I knew you could!
My first attempt to download (with ADMIN privledge) failed... so I tried to delete that folder and got an error... so that is when I tried to "Contact" Microsoft, and that is when I got *another* error which says JavaScript must be enabled... well it *is* enabled so there is some problem with Mircosoft directly... and when I try to "Contact" them, that is when I get the 2nd error.
If that ain't the definition of DOUBLE FAIL, then please correct me!
In the meantime, I have 0-byte file of "ms_community.exe" that I can't delete (even with admin privledges!)... and obviously I still need to download the real (non-zero-byte) install of "ms_community.exe"
Yeah, I know you guys aren't MS support staff, so I don't expect you to have an answer, but I just wanted to vent about how modern systems are just as pathetic (or more) compared to "old-school" technology!!!! Did I mention !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
Post by hydrophilic on Jan 29, 2015 8:33:39 GMT
FYI, each ! equals a 20-megaton nuclear bomb dropped on Redmond Washington in my imagination
Edit Venting aside, I do have the skills to "delete" the file by hacking the NTFS (win file system)... but I prefer not to do that because it may corrupt the file system... of course any/all suggestions are welcome! /Edit
Edit 2 I am so, SO, SO sorry for going off-topic, but really, I don't know how to deal with MS failure! /Edit 2
|
|
|
Post by VDC 8x2 on Jan 29, 2015 19:48:37 GMT
Before reinstalling clear all references to it in the registry. I have found that to help with troublesome installs.
|
|
|
Post by hydrophilic on Jan 31, 2015 9:23:06 GMT
As I reported in another (unrelated) post, I now am using a new PC with Win8 (yuck)... I don't have any version of MS C nor VB installed on this PC. So there are no "old" registry entries for me to delete... but I'll keep hacking away at this OS until it does what I want. (Do what I say, not what you want... stupid MS.)
|
|
|
Post by VDC 8x2 on Feb 27, 2015 3:54:30 GMT
Good news! New Code everyone! I have redone the code for my compressor from the ground up. Now to release it for beta. After looking at what I want to compress, I made the following changes: 1) reduce the code to rle and far copy. rle is 1 to 127 and 0 = 256. (LLLLLLL)1 ,(byte value) 2) the far copy is far copy is 2k with 2 to 8 bytes via 1 to 7 with 0 = 64 byte far copy. 2 bytes like this (HHH)(NNN)10 LLLLLLLL. H = high bits of distance, L = low bits of distance and N = bits of length. 3) If I did it right the windows part should use the setup install thing. 4) the commodore side loads at $1300. you could recompile elsewhere. The source address of the decompress file should be at $20 in low/high byte format. sys $1300,,x,y where x is high byte and y is low byte of vdc address you are decompressing to. now for the source code. assembly /* *********************************************************************************************** vdc decompress 29.01,2015 by vdc 8x2 sys 1300,,x,y
.x high byte vdc mem target .y low byte vdc mem target $20 is normal mem in lo/hi byte format *********************************************************************************************** */ .const VDCdata = $d601 .const VDCreg = $d600 .const MemAddress = $12 .const CopyBytes = $1e .const CopySource = $20 .const ReadWrite = $1f .const Source = $fd .const Scratch = $fb .const CopyFlag = $18
.macro MoValue(fromem,tomem) { lda #fromem sta tomem }
.macro VDCwait(temp) { Loop: bit VDCreg bpl Loop }
.macro Reljmp (address) { clc bcc address }
.macro WordInc(Address) { inc Address bne NoRoll inc Address+1 NoRoll: }
.pc = $1300 "Vdc Decompress"
// Subroutine code
start: :MoValue(MemAddress,VDCreg) :VDCwait(0) // wait for vdc to be ready stx VDCdata :MoValue(MemAddress + 1,VDCreg) sty VDCdata jmp Parse
MainLoop: :WordInc(Source) :VDCwait(0) Parse: ldy #$00 lda (Source),y lsr bcs RLEcode //run length decoding lsr bcs CopyCode //our vdc copy code RawCode: tax bne NotEnd rts //done peace out. NotEnd: :MoValue(ReadWrite,VDCreg) { Loop: :WordInc(Source) lda (Source),y //get next byte :VDCwait(0) sta VDCdata dex bne Loop } beq MainLoop RLEcode: { tax bne XnotZero dex // the count is zero so make it 255 XnotZero: :MoValue(CopyFlag,VDCreg) lda VDCdata and $7f sta VDCdata // set flag for fill :MoValue(ReadWrite,VDCreg) :VDCwait(0) // set reg to write :WordInc(Source) lda (Source),y // what data to write sta VDCdata :MoValue(CopyBytes,VDCreg) stx VDCdata // Fill x to vdc mem jmp MainLoop } CopyCode: { pha //save to stack for high bits later and #$07 //3 bits for 2 to 8 and 64 with zero bne NotZero lda #$3f //it zero so make it 63 NotZero: tax //put the copy count into x inx //x must be +1 to make it (2 to 8) or 64 :MoValue(CopyFlag,VDCreg) lda VDCdata ora #$80 //set copy bit sta VDCdata pla //get value back off stack and shift for high bits lsr lsr lsr sta Scratch //save the high bits :WordInc(Source) lda (Source),y sta Scratch + 1 //save the low byte :MoValue(MemAddress + 1,VDCreg) lda VDCdata sec //set carry we subtracting sbc Scratch + 1 sta Scratch + 1 // save low byte :MoValue(MemAddress,VDCreg) :VDCwait(0) lda VDCdata //got high byte sbc Scratch ldy #CopySource sty VDCreg sta VDCdata //store high byte address in vdc reg lda Scratch + 1 iny //now for low byte sty VDCreg sta VDCdata :MoValue(CopyBytes,VDCreg) :VDCwait(0) stx VDCdata //start our copy jmp MainLoop } end:
// Data Some of the visual basic code Public Class Form1 Dim loadButton As Boolean = False Dim compressButton As Boolean = False Dim saveButton As Boolean = False Dim slidingWindow As String Dim FutureWindow As String Dim distance As UInt32 Dim compressTarget As String Dim progressPointer As UInt32 = 1 Dim endOfProcess As UInt32 Dim futurEnd As UInt16 = 256 Dim outputString As String Dim anyCompression(2) As Boolean Dim stringCount(2) As UInt32 Dim howMany As UInt32 = 0 Dim raw As String
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click AboutBox1.ShowDialog() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click loadStuff() End Sub Private Sub LoadToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadToolStripMenuItem.Click loadStuff() End Sub
Private Sub loadStuff() loadButton = True ProgressBar1.Value = 1 OpenFileDialog1.ShowDialog() If OpenFileDialog1.FileName = "" Then loadButton = False 'no name so aborted load Return End If Dim bytes = My.Computer.FileSystem.ReadAllBytes(OpenFileDialog1.FileName) 'convert array into our workstring minus the load address compressTarget = ""
For index = 2 To bytes.GetUpperBound(0) compressTarget = compressTarget & Chr(bytes(index)) Next If Len(compressTarget) < 256 Then MsgBox("The compressed file must be at least 256 bytes") loadButton = False
Return End If endOfProcess = Len(compressTarget) 'load the future window
End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click CompresStuff() End Sub Private Sub CompressToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CompressToolStripMenuItem.Click CompresStuff() End Sub Private Sub CompresStuff() If loadButton = False Then MsgBox("load file first.") Return End If progressPointer = 1 FutureWindow = Mid(compressTarget, 1, 256) slidingWindow = "" outputString = "" raw = "" compressButton = True ' start of encoding loop ProgressBar1.Minimum = 1 ProgressBar1.Maximum = Me.endOfProcess ProgressBar1.Value = 1 stringCount(0) = 0 'for the raw section Do For varP = 1 To 2 stringCount(varP) = 0 anyCompression(varP) = False If varP = 1 Then For relVar = 2 To futurEnd 'checking run length If Mid(FutureWindow, 1, 1) = Mid(FutureWindow, relVar, 1) Then anyCompression(1) = True stringCount(1) = stringCount(1) + 1
Else Exit For End If Next End If If varP = 2 Then For farVar = 1 To 1983 If Mid(FutureWindow, 1, 64) = Mid(slidingWindow, farVar, 64) Then 'checking for far 64 first anyCompression(2) = True stringCount(2) = 63 distance = farVar Exit For End If Next If anyCompression(2) = False Then For x = 8 To 2 Step -1 For farVar = 1 To 2047 - x If Mid(FutureWindow, 1, x) = Mid(slidingWindow, farVar, x) Then anyCompression(2) = True stringCount(2) = x - 1 distance = farVar Exit For End If Next If anyCompression(2) = True Then Exit For Next End If End If Next
If anyCompression(1) = True And anyCompression(2) = False Then 'no copy compression so do rle Comp1() End If If anyCompression(1) = False And anyCompression(2) = True Then 'no rle so do copy compression Comp2() End If If anyCompression(1) = True And anyCompression(2) = True And anyCompression(1) >= anyCompression(2) Then 'rle is >= copy so do rle compression. the tie goes to rle Comp1() End If If anyCompression(1) = True And anyCompression(2) = True And anyCompression(1) < anyCompression(2) Then 'rle is < copy so do copy compression Comp2() End If If anyCompression(1) = False And anyCompression(2) = False Then 'no compression opportunities, so move to next byte and try again. raw = raw & Mid(FutureWindow, 1, 1) If Len(raw) = 63 Then outputString = outputString & Chr(63 * 4) & raw raw = "" End If howMany = 0 End If 'MsgBox(stringCount(1) & " " & stringCount(2)) updateFuture(stringCount(howMany)) If progressPointer > endOfProcess Then Exit Do End If ProgressBar1.Value = progressPointer Loop If raw <> "" Then outputString = outputString & Chr(Len(raw) * 4) & raw raw = "" End If ProgressBar1.Value = endOfProcess outputString = Chr(0) & outputString & Chr(0) 'padding for start and end of file for the end
End Sub Private Sub Comp1() Dim rleCount As UInt32 If stringCount(1) = 255 Then rleCount = 0 End If If stringCount(1) > 127 And stringCount(1) < 255 Then stringCount(1) = 127 rleCount = stringCount(1) End If If stringCount(1) <= 127 Then rleCount = stringCount(1) End If If raw <> "" Then outputString = outputString & Chr(Len(raw) * 4) & raw raw = "" End If outputString = outputString & Chr(rleCount * 2 + 1) & Mid(FutureWindow, 1, 1) howMany = 1 End Sub Private Sub Comp2() Dim farCount As UInt32 distance = 2047 - distance 'turning it around to make it be the right distance from futureWindow If stringCount(2) = 63 Then farCount = 0 '0 will = 64 in the decompression code Else farCount = stringCount(2) End If If raw <> "" Then outputString = outputString & Chr(Len(raw) * 4) & raw raw = "" End If outputString = outputString & Chr(((((distance And 1792) / 256) * 8) + farCount) * 4 + 2) & Chr(distance And 255) '(hhhnnn * 4) +2 first byte, llllllll second byte. distance = hhh,llllllll howMany = 2 End Sub Private Sub updateFuture(x As UInt16) If x = 0 Then 'process just one sliding window move slidingWindow = slidingWindow & Mid(FutureWindow, 1, 1) If Len(slidingWindow) > 2047 Then slidingWindow = Mid(slidingWindow, 2, 2047) 'make sure it tops out at 2047 bytes End If FutureWindow = Mid(FutureWindow, 2, 256) & Mid(compressTarget, progressPointer, 1) 'move a byte from furture to sliding progressPointer = progressPointer + 1 Else For loop1 As UInt32 = 1 To x + 1 'proccess x+1 sliding window moves slidingWindow = slidingWindow & Mid(FutureWindow, 1, 1) If Len(slidingWindow) > 2047 Then slidingWindow = Mid(slidingWindow, 2, 2047) 'make sure it tops out at 2047 bytes End If FutureWindow = Mid(FutureWindow, 2, 256) & Mid(compressTarget, progressPointer, 1) 'move a byte from furture to sliding progressPointer = progressPointer + 1 Next End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click saveStuff() End Sub Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click saveStuff() End Sub Private Sub saveStuff() If loadButton = False Or compressButton = False Then MsgBox("Load file or compress before saving.") Else loadButton = False compressButton = False saveButton = True SaveFileDialog1.FileName = OpenFileDialog1.FileName & ".vdcp" SaveFileDialog1.ShowDialog() ProgressBar1.Value = 1 ProgressBar1.Maximum = Len(outputString) Dim outputFile(Len(outputString)) As Byte For index = 1 To Len(outputString) outputFile(index) = Asc(Mid(outputString, index, 1)) ProgressBar1.Value = index Next ProgressBar1.Value = Len(outputString) My.Computer.FileSystem.WriteAllBytes(SaveFileDialog1.FileName, outputFile, False) End If
End Sub Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click End End Sub End Class
The software is ready for testing. Have at an tell me about any bugs. Let the beta begin! Attachments:vdCrush.zip (265.79 KB)
vdcrush.d64 (170.75 KB)
|
|
|
Post by VDC 8x2 on Feb 27, 2015 4:11:28 GMT
forgot to say that the source file need to have a 2 byte load address. like it had been bsaved on the c128 side.
|
|